TxTranslation
TxTranslation copied to clipboard
Dictionary from embedded resource gets lost when using filewatchers
Hi,
we are loading dictionaries from both an embedded resource and from XML files. The embedded resource acts as a fallback when the user does not provide a complete txd file.
When we have Tx.UseFileSystemWatcher = true, and modify a txd file, the keys from the embedded resource get thrown away.
This is kind of counter-intuitive, and I don't think there is a workaround for it. IMHO, Tx.CheckReloadFiles() should not overwrite the entire global dictionary.
To be honest I don't know how to solve this right now. When reloading files, there shouldn't be any keys left from the previously loaded file. But all keys are stored in a single shared dictionary. There is no tracking about where it came from, so it can be excluded from clearing. That wouldn't help anyway because a key might be added before, then overwritten from a file, and when the file changes, it needs to revert to what was loaded first.
The only thing that comes to my mind now is an event that tells you that files have changed, so you could reload things yourself they way you need it. Would that be an option for you?
Hi, Thank you for answering and sorry for my late response. I see now, that this is more complicated. You would need to track every source with timestamp and merge them again in order. An event on changed files would help a bit, but I guess we could just as well use our own file watcher. Feel free to just close the issue.