public ISpellingDictionary GetDictionary(ITextBuffer buffer)
{
ISpellingDictionary service;
if (buffer.Properties.TryGetProperty(typeof(SpellingDictionaryService), out service))
return service;
if (GlobalDictionary == null)
GlobalDictionary = new GlobalDictionary();
List<ISpellingDictionary> bufferSpecificDictionaries = new List<ISpellingDictionary>();
foreach (var provider in BufferSpecificDictionaryProviders)
{
var dictionary = provider.Value.GetDictionary(buffer);
if (dictionary != null)
bufferSpecificDictionaries.Add(dictionary);
}
service = new SpellingDictionaryService(bufferSpecificDictionaries, GlobalDictionary);
buffer.Properties[typeof(SpellingDictionaryService)] = service;
return service;
}