TextEditorFontSettings Create(string category)
        {
            if (category == null)
            {
                return(null);
            }
            TextEditorFontSettings settings;

            if (Result.TryGetValue(category, out settings))
            {
                return(settings);
            }

            Lazy <TextEditorFormatDefinition, ITextEditorFormatDefinitionMetadata> def;

            if (!toDef.TryGetValue(category, out def))
            {
                return(null);
            }

            Debug.Assert(def.Metadata.BaseDefinition == null || def.Metadata.BaseDefinition.Count() == 1);
            var baseType = Create(def.Metadata.BaseDefinition?.FirstOrDefault()) ?? DefaultSettings;

            settings = new TextEditorFontSettings(textEditorSettings, def, baseType);
            Result.Add(category, settings);
            return(settings);
        }
Пример #2
0
 public TextEditorFontSettings(ITextEditorSettings textEditorSettings, Lazy <TextEditorFormatDefinition, ITextEditorFormatDefinitionMetadata> textEditorFormatDefinition, TextEditorFontSettings baseType)
 {
     this.textEditorFormatDefinition = textEditorFormatDefinition;
     this.baseType = baseType;
     if (baseType != null)
     {
         baseType.SettingsChanged += BaseType_SettingsChanged;
     }
     //TODO: Don't use the global settings
     textEditorSettings.PropertyChanged += TextEditorSettings_PropertyChanged;
 }
        public TextEditorFontSettingsDictionaryProvider(ITextEditorSettings textEditorSettings, IEnumerable <Lazy <TextEditorFormatDefinition, ITextEditorFormatDefinitionMetadata> > textEditorFormatDefinitions)
        {
            Result          = new Dictionary <string, TextEditorFontSettings>(StringComparer.Ordinal);
            DefaultSettings = CreateDefaultTextEditorFontSettings(textEditorSettings);
            Result.Add(AppearanceCategoryConstants.TextEditor, DefaultSettings);
            this.textEditorSettings = textEditorSettings;
            this.toDef = new Dictionary <string, Lazy <TextEditorFormatDefinition, ITextEditorFormatDefinitionMetadata> >(StringComparer.Ordinal);
            var allDefs = textEditorFormatDefinitions.ToArray();

            foreach (var def in allDefs)
            {
                Debug.Assert(!toDef.ContainsKey(def.Metadata.Name));
                toDef[def.Metadata.Name] = def;
            }
            foreach (var def in allDefs)
            {
                Create(def.Metadata.Name);
            }
        }