コード例 #1
0
 TextViewOptionsGroupService(ISettingsService settingsService, IContentTypeRegistryService contentTypeRegistryService, [ImportMany] IEnumerable <Lazy <ITextViewOptionsGroupNameProvider, ITextViewOptionsGroupNameProviderMetadata> > textViewOptionsGroupNameProviders, [ImportMany] IEnumerable <Lazy <IContentTypeOptionDefinitionProvider, IContentTypeOptionDefinitionProviderMetadata> > contentTypeOptionDefinitionProviders)
 {
     nameToGroup = new Dictionary <string, TextViewOptionsGroup>(StringComparer.Ordinal);
     this.contentTypeRegistryService           = contentTypeRegistryService;
     this.textViewOptionsGroupNameProviders    = textViewOptionsGroupNameProviders.OrderBy(a => a.Metadata.Order).ToArray();
     this.contentTypeOptionDefinitionProviders = contentTypeOptionDefinitionProviders.OrderBy(a => a.Metadata.Order).ToArray();
     optionsStorage = new OptionsStorage(settingsService);
 }
コード例 #2
0
        public TextViewOptionsGroup(string groupName, IContentTypeRegistryService contentTypeRegistryService, ContentTypeOptionDefinition[] defaultOptions, OptionsStorage optionsStorage)
        {
            if (groupName == null)
            {
                throw new ArgumentNullException(nameof(groupName));
            }
            if (contentTypeRegistryService == null)
            {
                throw new ArgumentNullException(nameof(contentTypeRegistryService));
            }
            if (defaultOptions == null)
            {
                throw new ArgumentNullException(nameof(defaultOptions));
            }
            if (optionsStorage == null)
            {
                throw new ArgumentNullException(nameof(optionsStorage));
            }
            this.contentTypeRegistryService = contentTypeRegistryService;
            textViews      = new List <IWpfTextView>();
            toOptions      = new Dictionary <IContentType, TextViewGroupOptionCollection>();
            this.groupName = groupName;

            foreach (var option in defaultOptions)
            {
                Debug.Assert(option.Name != null);
                if (option.Name == null)
                {
                    continue;
                }

                var ct = option.ContentType == null ? null : contentTypeRegistryService.GetContentType(option.ContentType);
                Debug.Assert(ct != null);
                if (ct == null)
                {
                    continue;
                }

                TextViewGroupOptionCollection coll;
                if (!toOptions.TryGetValue(ct, out coll))
                {
                    toOptions.Add(ct, coll = new TextViewGroupOptionCollection(ct));
                }
                coll.Add(new TextViewGroupOption(this, option));
            }

            foreach (var coll in toOptions.Values)
            {
                optionsStorage.InitializeOptions(groupName, coll);
            }
            this.optionsStorage = optionsStorage;
        }