private static IEnumerable<ConfigurationSectionManageabilityProviderData> GetConfigurationManageabilityProviders(
            ConfigurationManageabilityProviderAttributeRetriever retriever)
        {
            foreach (var sectionAttribute in retriever.SectionManageabilityProviderAttributes)
            {
                var sectionProviderElement =
                    new ConfigurationSectionManageabilityProviderData(
                        sectionAttribute.SectionName,
                        sectionAttribute.ManageabilityProviderType);

                foreach (var elementAttribute in retriever.ElementManageabilityProviderAttributes)
                {
                    if (elementAttribute.SectionManageabilityProviderType == sectionAttribute.ManageabilityProviderType)
                    {
                        sectionProviderElement.ManageabilityProviders.Add(
                            new ConfigurationElementManageabilityProviderData(
                                elementAttribute.TargetType.Name,
                                elementAttribute.ManageabilityProviderType,
                                elementAttribute.TargetType));
                    }
                }

                yield return sectionProviderElement;
            }
        }
示例#2
0
        private static IDictionary <String, ConfigurationSectionManageabilityProvider> GetManageabilityProviders()
        {
            IDictionary <String, ConfigurationSectionManageabilityProvider> manageabilityProviders
                = new Dictionary <String, ConfigurationSectionManageabilityProvider>();

            ConfigurationManageabilityProviderAttributeRetriever retriever
                = new ConfigurationManageabilityProviderAttributeRetriever();

            foreach (ConfigurationSectionManageabilityProviderAttribute sectionAttribute
                     in retriever.SectionManageabilityProviderAttributes)
            {
                IDictionary <Type, ConfigurationElementManageabilityProvider> subProviders
                    = new Dictionary <Type, ConfigurationElementManageabilityProvider>();

                foreach (ConfigurationElementManageabilityProviderAttribute elementAttribute
                         in retriever.ElementManageabilityProviderAttributes)
                {
                    if (elementAttribute.SectionManageabilityProviderType
                        == sectionAttribute.ManageabilityProviderType)
                    {
                        subProviders.Add(elementAttribute.TargetType,
                                         (ConfigurationElementManageabilityProvider)Activator.CreateInstance(elementAttribute.ManageabilityProviderType));
                    }
                }

                manageabilityProviders.Add(sectionAttribute.SectionName,
                                           (ConfigurationSectionManageabilityProvider)Activator.CreateInstance(sectionAttribute.ManageabilityProviderType, subProviders));
            }

            return(manageabilityProviders);
        }
 public ExportAdmTemplateCommand(CommandAttribute commandAttribute,
                                 ApplicationViewModel applicationViewModel,
                                 IUIServiceWpf uiService,
                                 ElementViewModel element,
                                 AssemblyLocator assemblyLocator)
     : base(commandAttribute, uiService)
 {
     this.applicationViewModel = applicationViewModel;
     this.element = element;
     this.attributeRetriever = new ConfigurationManageabilityProviderAttributeRetriever(assemblyLocator);
 }
        public override void Initialize(InitializeContext context)
        {
            var sourceElement = this.ConfigurationElement as ManageableConfigurationSourceElement;
            if (sourceElement != null)
            {
                sourceElement.ConfigurationManageabilityProviders.Clear();

                var retriever = new ConfigurationManageabilityProviderAttributeRetriever(this.assemblyLocator);
                foreach (var sectionProviderElement in GetConfigurationManageabilityProviders(retriever))
                {
                    sourceElement.ConfigurationManageabilityProviders.Add(sectionProviderElement);
                }
            }
        }
示例#5
0
        public void CanLoadAttributesFromAssembly()
        {
            List <ConfigurationSectionManageabilityProviderAttribute> sectionManageabilityProviderAttributes
                = new List <ConfigurationSectionManageabilityProviderAttribute>();
            List <ConfigurationElementManageabilityProviderAttribute> elementManageabilityProviderAttributes
                = new List <ConfigurationElementManageabilityProviderAttribute>();

            String[] assemblyNames = new String[] { Assembly.GetExecutingAssembly().GetName().Name + ".dll" };
            ConfigurationManageabilityProviderAttributeRetriever retriever = new ConfigurationManageabilityProviderAttributeRetriever(assemblyNames);

            sectionManageabilityProviderAttributes.AddRange(retriever.SectionManageabilityProviderAttributes);
            elementManageabilityProviderAttributes.AddRange(retriever.ElementManageabilityProviderAttributes);
            Assert.AreEqual(1, sectionManageabilityProviderAttributes.Count);
            Assert.AreEqual("section1", sectionManageabilityProviderAttributes[0].SectionName);
            Assert.AreSame(typeof(MockConfigurationSectionManageabilityProvider), sectionManageabilityProviderAttributes[0].ManageabilityProviderType);
            Assert.AreEqual(1, elementManageabilityProviderAttributes.Count);
        }
示例#6
0
 public ManageableConfigurationSourceElementBuilder(ManageableConfigurationSourceElementNode node,
                                                    ConfigurationManageabilityProviderAttributeRetriever retriever)
 {
     this.node      = node;
     this.retriever = retriever;
 }