//===================================================================== /// <inheritdoc /> public ISpellingDictionary GetDictionary(ITextBuffer buffer) { ISpellingDictionary service = null; if (buffer.Properties.TryGetProperty(typeof(SpellingDictionaryService), out service)) { return(service); } List <ISpellingDictionary> bufferSpecificDictionaries = new List <ISpellingDictionary>(); foreach (var provider in bufferSpecificDictionaryProviders) { var dictionary = provider.Value.GetDictionary(buffer); if (dictionary != null) { bufferSpecificDictionaries.Add(dictionary); } } // Create or get the existing global dictionary for the default language var globalDictionary = GlobalDictionary.CreateGlobalDictionary(null); if (globalDictionary != null) { service = new SpellingDictionaryService(bufferSpecificDictionaries, globalDictionary); buffer.Properties[typeof(SpellingDictionaryService)] = service; } return(service); }
/// <summary> /// This is used to register a spelling dictionary service with the global dictionary so that it is /// notified of changes to the global dictionary. /// </summary> /// <param name="service">The dictionary service to register</param> public void RegisterSpellingDictionaryService(SpellingDictionaryService service) { // Clear out ones that have been disposed of foreach (var svc in registeredServices.Where(s => !s.IsAlive).ToArray()) { registeredServices.Remove(svc); } System.Diagnostics.Debug.WriteLine("Registered services count: {0}", registeredServices.Count); registeredServices.Add(new WeakReference(service)); }