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; } }
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); } } }
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); }
public ManageableConfigurationSourceElementBuilder(ManageableConfigurationSourceElementNode node, ConfigurationManageabilityProviderAttributeRetriever retriever) { this.node = node; this.retriever = retriever; }