Exemplo n.º 1
0
 HexViewOptionsGroupServiceImpl(ISettingsService settingsService, [ImportMany] IEnumerable <Lazy <HexViewOptionsGroupNameProvider, IHexViewOptionsGroupNameProviderMetadata> > hexViewOptionsGroupNameProviders, [ImportMany] IEnumerable <Lazy <TagOptionDefinitionProvider, ITagOptionDefinitionProviderMetadata> > tagOptionDefinitionProviders)
 {
     nameToGroup = new Dictionary <string, HexViewOptionsGroupImpl>(StringComparer.Ordinal);
     this.hexViewOptionsGroupNameProviders = hexViewOptionsGroupNameProviders.OrderBy(a => a.Metadata.Order).ToArray();
     this.tagOptionDefinitionProviders     = tagOptionDefinitionProviders.OrderBy(a => a.Metadata.Order).ToArray();
     optionsStorage = new OptionsStorage(settingsService);
 }
Exemplo n.º 2
0
        public HexViewOptionsGroupImpl(HexViewOptionsGroupServiceImpl owner, string groupName, TagOptionDefinition[] defaultOptions, OptionsStorage optionsStorage)
        {
            if (owner == null)
            {
                throw new ArgumentNullException(nameof(owner));
            }
            if (groupName == null)
            {
                throw new ArgumentNullException(nameof(groupName));
            }
            if (defaultOptions == null)
            {
                throw new ArgumentNullException(nameof(defaultOptions));
            }
            if (optionsStorage == null)
            {
                throw new ArgumentNullException(nameof(optionsStorage));
            }
            this.owner     = owner;
            hexViews       = new List <WpfHexView>();
            toOptions      = new Dictionary <string, HexViewGroupOptionCollection>(StringComparer.OrdinalIgnoreCase);
            this.groupName = groupName;

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

                var subGroup = option.SubGroup;
                Debug.Assert(subGroup != null);
                if (subGroup == null)
                {
                    continue;
                }

                HexViewGroupOptionCollection coll;
                if (!toOptions.TryGetValue(subGroup, out coll))
                {
                    toOptions.Add(subGroup, coll = new HexViewGroupOptionCollection(subGroup));
                }
                coll.Add(new HexViewGroupOption(this, option));
            }

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