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);
            }
        }
Esempio n. 2
0
 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);
                }
            }
        }