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);
        }
        public SpellingDictionaryService(IList<ISpellingDictionary> bufferSpecificDictionaries, GlobalDictionary globalDictionary)
        {
            _bufferSpecificDictionaries = bufferSpecificDictionaries;
            _globalDictionary = globalDictionary;

            foreach (var dictionary in _bufferSpecificDictionaries)
            {
                dictionary.DictionaryUpdated += BufferSpecificDictionaryUpdated;
            }

            // Register to receive events when the global dictionary is updated
            _globalDictionary.RegisterSpellingDictionaryService(this);
        }
        public SpellingDictionaryService(IList <ISpellingDictionary> bufferSpecificDictionaries, GlobalDictionary globalDictionary)
        {
            _bufferSpecificDictionaries = bufferSpecificDictionaries;
            _globalDictionary           = globalDictionary;

            foreach (var dictionary in _bufferSpecificDictionaries)
            {
                dictionary.DictionaryUpdated += BufferSpecificDictionaryUpdated;
            }

            // Register to receive events when the global dictionary is updated
            _globalDictionary.RegisterSpellingDictionaryService(this);
        }
        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;
        }