private void OnRecordPropertyChanged(object sender, PropertyChangedEventArgs e) { VerifyNotDisposed(); LexEntry entry = (LexEntry)sender; switch (e.PropertyName) { // these are changes to the list not a change that needs to clean up // and can actually have very detrimental effect if we do. case "exampleSentences": case "senses": break; default: //this is to fix WS-238. The scenario is this: //a paste operation starts by erasing the target... this fired off a cleanup //and then the new text came in so fast that we got various crashes. //With this, we just schedule a cleanup, as a ui event handler, for //a moment in the future. The interval is chosen to allow even a quick //backspace followed by typing, without wiping out the sense/example. if (_cleanupTimer == null) { _cleanupTimer = new Timer(); _cleanupTimer.Tick += OnCleanupTimer_Tick; _cleanupTimer.Interval = 500; } _cleanupTimer.Tag = entry; _cleanupTimer.Stop(); //reset it _cleanupTimer.Start(); break; } _lexEntryRepository.NotifyThatLexEntryHasBeenUpdated((LexEntry)sender); // can't afford to do this every keystroke, with large files }
public void NotifyThatLexEntryHasBeenUpdated_LexEntry_CachesAreUpdated() { LexEntry entryToUpdate = _repository.CreateItem(); entryToUpdate.LexicalForm.SetAlternative("de", "word 0"); _repository.SaveItem(entryToUpdate); CreateCaches(); entryToUpdate.LexicalForm.SetAlternative("de", "word 1"); _repository.NotifyThatLexEntryHasBeenUpdated(entryToUpdate); IWritingSystemDefinition writingSystemToMatch = WritingSystemDefinition.Parse("de"); ResultSet <LexEntry> headWordResults = _repository.GetAllEntriesSortedByHeadword(writingSystemToMatch); ResultSet <LexEntry> lexicalFormResults = _repository.GetAllEntriesSortedByLexicalFormOrAlternative(writingSystemToMatch); Assert.AreEqual("word 1", headWordResults[0]["Form"]); Assert.AreEqual("word 1", lexicalFormResults[0]["Form"]); }
private void OnEntryChanged(object sender, PropertyChangedEventArgs e) { _lexEntryRepository.NotifyThatLexEntryHasBeenUpdated((LexEntry)sender); }