protected override void AddAdministrativeTemplateDirectives(
            AdmContentBuilder contentBuilder,
            DatabaseSettings configurationSection,
            IConfigurationSource configurationSource,
            string sectionKey)
        {
            contentBuilder.StartPolicy(Resources.DatabaseSettingsPolicyName, sectionKey);
            List <AdmDropDownListItem> dropDownListItemList = new List <AdmDropDownListItem>();
            ConnectionStringsSection   section = (ConnectionStringsSection)configurationSource.GetSection("connectionStrings");

            if (section != null)
            {
                foreach (ConnectionStringSettings connectionString in (ConfigurationElementCollection)section.ConnectionStrings)
                {
                    dropDownListItemList.Add(new AdmDropDownListItem(connectionString.Name, connectionString.Name));
                }
            }
            contentBuilder.AddDropDownListPart(Resources.DatabaseSettingsDefaultDatabasePartName, "defaultDatabase", (IEnumerable <AdmDropDownListItem>)dropDownListItemList, configurationSection.DefaultDatabase);
            contentBuilder.EndPolicy();
            if (configurationSection.ProviderMappings.Count <= 0)
            {
                return;
            }
            contentBuilder.StartCategory(Resources.ProviderMappingsCategoryName);
            foreach (DbProviderMapping providerMapping in configurationSection.ProviderMappings)
            {
                contentBuilder.StartPolicy(string.Format((IFormatProvider)CultureInfo.InvariantCulture, Resources.ProviderMappingPolicyNameTemplate, (object)providerMapping.Name), sectionKey + "\\providerMappings\\" + providerMapping.Name);
                contentBuilder.AddComboBoxPart(Resources.ProviderMappingDatabaseTypePartName, "databaseType", providerMapping.DatabaseType.AssemblyQualifiedName, (int)byte.MaxValue, false, DatabaseSettingsManageabilityProvider.DatabaseTypeNames);
                contentBuilder.EndPolicy();
            }
            contentBuilder.EndCategory();
        }
        /// <summary>
        /// <para>This method supports the Enterprise Library Manageability Extensions infrastructure and is not intended to
        /// be used directly from your code.</para>
        /// Adds the ADM instructions that describe the policies that can be used to override the configuration
        /// information for the Exception Handling Application Block.
        /// </summary>
        /// <seealso cref="ConfigurationSectionManageabilityProvider.AddAdministrativeTemplateDirectives(AdmContentBuilder, ConfigurationSection, IConfigurationSource, String)"/>
        protected override void AddAdministrativeTemplateDirectives(AdmContentBuilder contentBuilder,
                                                                    ExceptionHandlingSettings configurationSection,
                                                                    IConfigurationSource configurationSource,
                                                                    String sectionKey)
        {
            contentBuilder.StartPolicy(Resources.SectionPolicyName,
                                       sectionKey);
            contentBuilder.EndPolicy();

            foreach (ExceptionPolicyData policy in configurationSection.ExceptionPolicies)
            {
                contentBuilder.StartCategory(policy.Name);
                {
                    String exceptionTypesKey = sectionKey
                                               + @"\" + PoliciesKeyName
                                               + @"\" + policy.Name
                                               + @"\" + PolicyTypesPropertyName;

                    foreach (ExceptionTypeData exceptionType in policy.ExceptionTypes)
                    {
                        String exceptionTypeKey = exceptionTypesKey + @"\" + exceptionType.Name;

                        contentBuilder.StartPolicy(String.Format(CultureInfo.CurrentCulture,
                                                                 Resources.ExceptionTypePolicyNameTemplate,
                                                                 exceptionType.Name),
                                                   exceptionTypeKey);
                        {
                            contentBuilder.AddDropDownListPartForEnumeration <PostHandlingAction>(Resources.ExceptionTypePostHandlingActionPartName,
                                                                                                  PolicyTypePostHandlingActionPropertyName,
                                                                                                  exceptionType.PostHandlingAction);

                            contentBuilder.AddTextPart(Resources.ExceptionTypeHandlersPartName);

                            String exceptionHandlersKey = exceptionTypeKey + @"\" + PolicyTypeHandlersPropertyName;
                            foreach (ExceptionHandlerData handler in exceptionType.ExceptionHandlers)
                            {
                                ConfigurationElementManageabilityProvider subProvider = GetSubProvider(handler.GetType());

                                if (subProvider != null)
                                {
                                    AddAdministrativeTemplateDirectivesForElement <ExceptionHandlerData>(contentBuilder,
                                                                                                         handler, subProvider,
                                                                                                         configurationSource,
                                                                                                         exceptionHandlersKey);
                                }
                            }
                        }
                        contentBuilder.EndPolicy();
                    }
                }
                contentBuilder.EndCategory();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// <para>This method supports the Enterprise Library Manageability Extensions infrastructure and is not intended to
        /// be used directly from your code.</para>
        /// Adds the ADM instructions that describe the policies that can be used to override the configuration
        /// information for the Security Application Block.
        /// </summary>
        /// <seealso cref="ConfigurationSectionManageabilityProvider.AddAdministrativeTemplateDirectives(AdmContentBuilder, ConfigurationSection, IConfigurationSource, String)"/>
        protected override void AddAdministrativeTemplateDirectives(AdmContentBuilder contentBuilder,
                                                                    SecuritySettings configurationSection,
                                                                    IConfigurationSource configurationSource,
                                                                    String sectionKey)
        {
            contentBuilder.StartPolicy(Resources.SecuritySettingsPolicyName, sectionKey);
            {
                contentBuilder.AddDropDownListPartForNamedElementCollection <AuthorizationProviderData>(Resources.SecuritySettingsDefaultAuthorizationProviderPartName,
                                                                                                        DefaultAuthorizationProviderPropertyName,
                                                                                                        configurationSection.AuthorizationProviders,
                                                                                                        configurationSection.DefaultAuthorizationProviderName,
                                                                                                        true);

                contentBuilder.AddDropDownListPartForNamedElementCollection <SecurityCacheProviderData>(Resources.SecuritySettingsDefaultSecurityCacheProviderPartName,
                                                                                                        DefaultSecurityCacheProviderPropertyName,
                                                                                                        configurationSection.SecurityCacheProviders,
                                                                                                        configurationSection.DefaultSecurityCacheProviderName,
                                                                                                        true);
            }
            contentBuilder.EndPolicy();

            AddElementsPolicies <AuthorizationProviderData>(contentBuilder,
                                                            configurationSection.AuthorizationProviders,
                                                            configurationSource,
                                                            sectionKey + @"\" + AuthorizationProvidersKeyName,
                                                            Resources.AuthorizationProvidersCategoryName);
            AddElementsPolicies <SecurityCacheProviderData>(contentBuilder,
                                                            configurationSection.SecurityCacheProviders,
                                                            configurationSource,
                                                            sectionKey + @"\" + SecurityCacheProvidersKeyName,
                                                            Resources.SecurityCacheProvidersCategoryName);
        }
        private static void AddTraceSourcePolicy(
            TraceSourceData traceSourceData,
            String traceSourceName,
            String parentKey,
            AdmContentBuilder contentBuilder,
            LoggingSettings configurationSection)
        {
            String traceSourceKey = parentKey + @"\" + traceSourceName;

            contentBuilder.StartPolicy(String.Format(CultureInfo.InvariantCulture,
                                                     Resources.TraceSourcePolicyNameTemplate,
                                                     traceSourceName),
                                       traceSourceKey);
            {
                contentBuilder.AddDropDownListPartForEnumeration <SourceLevels>(Resources.TraceSourceDefaultLevelPartName,
                                                                                SourceDefaultLevelPropertyName,
                                                                                traceSourceData.DefaultLevel);

                contentBuilder.AddTextPart(Resources.TraceSourceListenersPartName);

                String traceSourceListenersKey = traceSourceKey + @"\" + SourceTraceListenersPropertyName;
                foreach (TraceListenerData traceListener in configurationSection.TraceListeners)
                {
                    contentBuilder.AddCheckboxPart(traceListener.Name,
                                                   traceSourceListenersKey,
                                                   traceListener.Name,
                                                   traceSourceData.TraceListeners.Contains(traceListener.Name),
                                                   true,
                                                   false);
                }
            }
            contentBuilder.EndPolicy();
        }
        private static void AddBlockSettingsPolicy(
            AdmContentBuilder contentBuilder,
            String sectionKey,
            LoggingSettings configurationSection)
        {
            contentBuilder.StartPolicy(Resources.LoggingSettingsPolicyName, sectionKey);
            {
                contentBuilder.AddDropDownListPartForNamedElementCollection <TraceSourceData>(
                    Resources.LoggingSettingsDefaultCategoryPartName,
                    DefaultCategoryPropertyName,
                    configurationSection.TraceSources,
                    configurationSection.DefaultCategory,
                    false);

                contentBuilder.AddCheckboxPart(Resources.LoggingSettingsLogWarningPartName,
                                               LogWarningOnNoMatchPropertyName,
                                               configurationSection.LogWarningWhenNoCategoriesMatch);

                contentBuilder.AddCheckboxPart(Resources.LoggingSettingsEnableTracingPartName,
                                               TracingEnabledPropertyName,
                                               configurationSection.TracingEnabled);

                contentBuilder.AddCheckboxPart(Resources.LoggingSettingsRevertImpersonationPartName,
                                               RevertImpersonationPropertyName,
                                               configurationSection.RevertImpersonation);
            }
            contentBuilder.EndPolicy();
        }
        /// <summary>
        /// Adds the ADM instructions that describe the policies that can be used to override the configuration
        /// information represented by a configuration section.
        /// </summary>
        /// <param name="contentBuilder">The <see cref="AdmContentBuilder"/> to which the Adm instructions are to be appended.</param>
        /// <param name="configurationSection">The configuration section instance.</param>
        /// <param name="configurationSource">The configuration source from where to get additional configuration
        /// information, if necessary.</param>
        /// <param name="sectionKey">The root key for the section's policies.</param>
        protected override void AddAdministrativeTemplateDirectives(AdmContentBuilder contentBuilder,
                                                                    ConnectionStringsSection configurationSection,
                                                                    IConfigurationSource configurationSource,
                                                                    String sectionKey)
        {
            contentBuilder.StartCategory(Resources.ConnectionStringsCategoryName);
            {
                foreach (ConnectionStringSettings connectionString in configurationSection.ConnectionStrings)
                {
                    contentBuilder.StartPolicy(String.Format(CultureInfo.InvariantCulture,
                                                             Resources.ConnectionStringPolicyNameTemplate,
                                                             connectionString.Name),
                                               sectionKey + @"\" + connectionString.Name);

                    contentBuilder.AddEditTextPart(Resources.ConnectionStringConnectionStringPartName,
                                                   ConnectionStringPropertyName,
                                                   connectionString.ConnectionString,
                                                   500,
                                                   true);

                    contentBuilder.AddComboBoxPart(Resources.ConnectionStringProviderNamePartName,
                                                   ProviderNamePropertyName,
                                                   connectionString.ProviderName,
                                                   255,
                                                   true,
                                                   "System.Data.SqlClient",
                                                   "System.Data.OracleClient");

                    contentBuilder.EndPolicy();
                }
            }
            contentBuilder.EndCategory();
        }
Exemplo n.º 7
0
        /// <summary>
        /// <para>This method supports the Enterprise Library Manageability Extensions infrastructure and is not intended to
        /// be used directly from your code.</para>
        /// Adds the ADM instructions that describe the policies that can be used to override the configuration
        /// information for the Cryptography Application Block.
        /// </summary>
        /// <seealso cref="ConfigurationSectionManageabilityProvider.AddAdministrativeTemplateDirectives(AdmContentBuilder, ConfigurationSection, IConfigurationSource, String)"/>
        protected override void AddAdministrativeTemplateDirectives(AdmContentBuilder contentBuilder,
                                                                    CryptographySettings configurationSection,
                                                                    IConfigurationSource configurationSource,
                                                                    String sectionKey)
        {
            contentBuilder.StartPolicy(Resources.CryptographySettingsPolicyName, sectionKey);
            {
                contentBuilder.AddDropDownListPartForNamedElementCollection <HashProviderData>(Resources.CryptographySettingsDefaultHashProviderPartName,
                                                                                               DefaultHashProviderPropertyName,
                                                                                               configurationSection.HashProviders,
                                                                                               configurationSection.DefaultHashProviderName,
                                                                                               true);

                contentBuilder.AddDropDownListPartForNamedElementCollection <SymmetricProviderData>(Resources.CryptographySettingsDefaultSymmetricCryptoProviderPartName,
                                                                                                    DefaultSymmetricCryptoProviderPropertyName,
                                                                                                    configurationSection.SymmetricCryptoProviders,
                                                                                                    configurationSection.DefaultSymmetricCryptoProviderName,
                                                                                                    true);
            }
            contentBuilder.EndPolicy();

            AddElementsPolicies <HashProviderData>(contentBuilder,
                                                   configurationSection.HashProviders,
                                                   configurationSource,
                                                   sectionKey + @"\" + HashProvidersKeyName,
                                                   Resources.HashProvidersCategoryName);
            AddElementsPolicies <SymmetricProviderData>(contentBuilder,
                                                        configurationSection.SymmetricCryptoProviders,
                                                        configurationSource,
                                                        sectionKey + @"\" + SymmetricCryptoProvidersKeyName,
                                                        Resources.SymmetricCryptoProvidersCategoryName);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Adds the ADM instructions that describe the policies that can be used to override the configuration
        /// information represented by a configuration section.
        /// </summary>
        /// <param name="contentBuilder">The <see cref="AdmContentBuilder"/> to which the Adm instructions are to be appended.</param>
        /// <param name="configurationSection">The configuration section instance.</param>
        /// <param name="configurationSource">The configuration source from where to get additional configuration
        /// information, if necessary.</param>
        /// <param name="sectionKey">The root key for the section's policies.</param>
        protected override void AddAdministrativeTemplateDirectives(AdmContentBuilder contentBuilder,
                                                                    OracleConnectionSettings configurationSection,
                                                                    IConfigurationSource configurationSource,
                                                                    String sectionKey)
        {
            contentBuilder.StartCategory(Resources.OracleConnectionsCategoryName);
            {
                foreach (OracleConnectionData data in configurationSection.OracleConnectionsData)
                {
                    String connectionPolicyKey = sectionKey + @"\" + data.Name;

                    contentBuilder.StartPolicy(String.Format(CultureInfo.InvariantCulture,
                                                             Resources.OracleConnectionPolicyNameTemplate,
                                                             data.Name),
                                               connectionPolicyKey);
                    {
                        contentBuilder.AddEditTextPart(Resources.OracleConnectionPackagesPartName,
                                                       PackagesPropertyName,
                                                       GenerateRulesString(data.Packages),
                                                       1024,
                                                       true);
                    }
                    contentBuilder.EndPolicy();
                }
            }
            contentBuilder.EndCategory();
        }
        /// <summary>
        /// Adds the ADM instructions that describe the policies that can be used to override the configuration
        /// information represented by a configuration section.
        /// </summary>
        /// <param name="contentBuilder">The <see cref="AdmContentBuilder"/> to which the Adm instructions are to be appended.</param>
        /// <param name="configurationSection">The configuration section instance.</param>
        /// <param name="configurationSource">The configuration source from where to get additional configuration
        /// information, if necessary.</param>
        /// <param name="sectionKey">The root key for the section's policies.</param>
        protected override void AddAdministrativeTemplateDirectives(AdmContentBuilder contentBuilder,
                                                                    DatabaseSettings configurationSection,
                                                                    IConfigurationSource configurationSource, String sectionKey)
        {
            contentBuilder.StartPolicy(Resources.DatabaseSettingsPolicyName, sectionKey);
            {
                List <AdmDropDownListItem> connectionStrings = new List <AdmDropDownListItem>();
                ConnectionStringsSection   connectionStringsSection
                    = (ConnectionStringsSection)configurationSource.GetSection("connectionStrings");
                if (connectionStringsSection != null)
                {
                    foreach (ConnectionStringSettings connectionString in connectionStringsSection.ConnectionStrings)
                    {
                        connectionStrings.Add(new AdmDropDownListItem(connectionString.Name, connectionString.Name));
                    }
                }
                contentBuilder.AddDropDownListPart(Resources.DatabaseSettingsDefaultDatabasePartName,
                                                   DefaultDatabasePropertyName,
                                                   connectionStrings,
                                                   configurationSection.DefaultDatabase);
            }
            contentBuilder.EndPolicy();

            if (configurationSection.ProviderMappings.Count > 0)
            {
                contentBuilder.StartCategory(Resources.ProviderMappingsCategoryName);
                {
                    foreach (DbProviderMapping providerMapping in configurationSection.ProviderMappings)
                    {
                        contentBuilder.StartPolicy(String.Format(CultureInfo.InvariantCulture,
                                                                 Resources.ProviderMappingPolicyNameTemplate,
                                                                 providerMapping.Name),
                                                   sectionKey + @"\" + ProviderMappingsKeyName + @"\" + providerMapping.Name);

                        contentBuilder.AddComboBoxPart(Resources.ProviderMappingDatabaseTypePartName,
                                                       DatabaseTypePropertyName,
                                                       providerMapping.DatabaseType.AssemblyQualifiedName,
                                                       255,
                                                       false,
                                                       DatabaseTypeNames);

                        contentBuilder.EndPolicy();
                    }
                }
                contentBuilder.EndCategory();
            }
        }
 static void AddAdministrativeTemplateDirectivesForSection(AdmContentBuilder contentBuilder,
                                                           CacheManagerSettings configurationSection,
                                                           String sectionKey)
 {
     contentBuilder.StartPolicy(Resources.CacheManagerSettingsPolicyName, sectionKey);
     {
         contentBuilder.AddDropDownListPartForNamedElementCollection(Resources.CacheManagerSettingsDefaultCacheManagerPartName,
                                                                     DefaultCacheManagerPropertyName,
                                                                     configurationSection.CacheManagers,
                                                                     configurationSection.DefaultCacheManager,
                                                                     false);
     }
     contentBuilder.EndPolicy();
 }
Exemplo n.º 11
0
 protected override void AddAdministrativeTemplateDirectives(
     AdmContentBuilder contentBuilder,
     OracleConnectionSettings configurationSection,
     IConfigurationSource configurationSource,
     string sectionKey)
 {
     contentBuilder.StartCategory(Resources.OracleConnectionsCategoryName);
     foreach (OracleConnectionData oracleConnectionData in configurationSection.OracleConnectionsData)
     {
         string policyKey = sectionKey + "\\" + oracleConnectionData.Name;
         contentBuilder.StartPolicy(string.Format((IFormatProvider)CultureInfo.InvariantCulture, Resources.OracleConnectionPolicyNameTemplate, (object)oracleConnectionData.Name), policyKey);
         contentBuilder.AddEditTextPart(Resources.OracleConnectionPackagesPartName, "packages", OracleConnectionSettingsManageabilityProvider.GenerateRulesString((IEnumerable <OraclePackageData>)oracleConnectionData.Packages), 1024, true);
         contentBuilder.EndPolicy();
     }
     contentBuilder.EndCategory();
 }
 protected override void AddAdministrativeTemplateDirectives(
     AdmContentBuilder contentBuilder,
     ConnectionStringsSection configurationSection,
     IConfigurationSource configurationSource,
     string sectionKey)
 {
     contentBuilder.StartCategory(Resources.ConnectionStringsCategoryName);
     foreach (ConnectionStringSettings connectionString in (ConfigurationElementCollection)configurationSection.ConnectionStrings)
     {
         contentBuilder.StartPolicy(string.Format((IFormatProvider)CultureInfo.InvariantCulture, Resources.ConnectionStringPolicyNameTemplate, (object)connectionString.Name), sectionKey + "\\" + connectionString.Name);
         contentBuilder.AddEditTextPart(Resources.ConnectionStringConnectionStringPartName, "connectionString", connectionString.ConnectionString, 500, true);
         contentBuilder.AddComboBoxPart(Resources.ConnectionStringProviderNamePartName, "providerName", connectionString.ProviderName, (int)byte.MaxValue, true, "System.Data.SqlClient", "System.Data.OracleClient");
         contentBuilder.EndPolicy();
     }
     contentBuilder.EndCategory();
 }
Exemplo n.º 13
0
 /// <summary>
 /// Adds the ADM instructions that describe the policies that can be used to override the properties of
 /// a specific instance of the configuration element type managed by the receiver.
 /// </summary>
 /// <param name="contentBuilder">The <see cref="AdmContentBuilder"/> to which the Adm instructions are to be appended.</param>
 /// <param name="configurationObject">The configuration object instance.</param>
 /// <param name="configurationSource">The configuration source from where to get additional configuration
 /// information, if necessary.</param>
 /// <param name="elementPolicyKeyName">The key for the element's policies.</param>
 /// <remarks>
 /// The default implementation for this method creates a policy, using
 /// <see cref="ConfigurationElementManageabilityProviderBase{T}.ElementPolicyNameTemplate"/> to create the policy name and invoking
 /// <see cref="ConfigurationElementManageabilityProviderBase{T}.AddElementAdministrativeTemplateParts(AdmContentBuilder, T, IConfigurationSource, String)"/>
 /// to add the policy parts.
 /// Subclasses managing objects that must not create a policy must override this method to just add the parts.
 /// </remarks>
 protected virtual void AddAdministrativeTemplateDirectives(AdmContentBuilder contentBuilder,
                                                            T configurationObject,
                                                            IConfigurationSource configurationSource,
                                                            String elementPolicyKeyName)
 {
     contentBuilder.StartPolicy(String.Format(CultureInfo.InvariantCulture,
                                              ElementPolicyNameTemplate,
                                              configurationObject.Name),
                                elementPolicyKeyName);
     {
         AddElementAdministrativeTemplateParts(contentBuilder,
                                               configurationObject,
                                               configurationSource,
                                               elementPolicyKeyName);
     }
     contentBuilder.EndPolicy();
 }
        public override void AddAdministrativeTemplateDirectives(AdmContentBuilder contentBuilder,
                                                                             ConfigurationElement configurationObject,
                                                                             IConfigurationSource configurationSource,
                                                                             String parentKey)
        {
            called = true;
            configurationObjects.Add(configurationObject);

            if (addPolicy)
                contentBuilder.StartPolicy(Policy, "policy");

            if (addPart)
                contentBuilder.AddTextPart(Part);

            if (addPolicy)
                contentBuilder.EndPolicy();
        }
        /// <summary>
        /// Adds the ADM instructions that describe the policies that can be used to override the configuration
        /// information represented by a configuration section.
        /// </summary>
        /// <param name="contentBuilder">The <see cref="AdmContentBuilder"/> to which the Adm instructions are to be appended.</param>
        /// <param name="configurationSection">The configuration section instance.</param>
        /// <param name="configurationSource">The configuration source from where to get additional configuration
        /// information, if necessary.</param>
        /// <param name="sectionKey">The root key for the section's policies.</param>
        protected override void AddAdministrativeTemplateDirectives(AdmContentBuilder contentBuilder,
                                                                    InstrumentationConfigurationSection configurationSection,
                                                                    IConfigurationSource configurationSource,
                                                                    String sectionKey)
        {
            contentBuilder.StartPolicy(Resources.InstrumentationSectionPolicyName, sectionKey);
            {
                contentBuilder.AddCheckboxPart(Resources.InstrumentationSectionEventLoggingEnabledPartName,
                                               EventLoggingEnabledPropertyName,
                                               configurationSection.EventLoggingEnabled);

                contentBuilder.AddCheckboxPart(Resources.InstrumentationSectionPerformanceCountersEnabledPartName,
                                               PerformanceCountersEnabledPropertyName,
                                               configurationSection.PerformanceCountersEnabled);
            }
            contentBuilder.EndPolicy();
        }
 public override void AddAdministrativeTemplateDirectives(AdmContentBuilder contentBuilder,
                                                          ConfigurationElement configurationObject,
                                                          IConfigurationSource configurationSource,
                                                          String parentKey)
 {
     called = true;
     configurationObjects.Add(configurationObject);
     if (addPolicy)
     {
         contentBuilder.StartPolicy(Policy, "policy");
     }
     if (addPart)
     {
         contentBuilder.AddTextPart(Part);
     }
     if (addPolicy)
     {
         contentBuilder.EndPolicy();
     }
 }
        public void EndPolicyFailsIfThereIsNoCurrentStartedPolicy()
        {
            AdmContentBuilder builder = new AdmContentBuilder();

            builder.EndPolicy();
        }
        /// <devdoc>
        /// ADM templates for caching are different from the other blocks' templates to match the configuration console's
        /// user experience. Instead of having separate categories with policies for cache managers, backing stores and
        /// encryption providers, the policy for a cache manager includes the parts for its backing store and eventual
        /// encryption provider.
        /// </devdoc>
        void AddAdministrativeTemplateDirectivesForCacheManagers(AdmContentBuilder contentBuilder,
                                                                 CacheManagerSettings configurationSection,
                                                                 IConfigurationSource configurationSource,
                                                                 String sectionKey)
        {
            String cacheManagersKey       = sectionKey + @"\" + CacheManagersKeyName;
            String backingStoresKey       = sectionKey + @"\" + BackingStoresKeyName;
            String encryptionProvidersKey = sectionKey + @"\" + EncryptionProvidersKeyName;

            contentBuilder.StartCategory(Resources.CacheManagersCategoryName);
            {
                foreach (CacheManagerDataBase cacheManagerDataBase in configurationSection.CacheManagers)
                {
                    if (cacheManagerDataBase is CustomCacheManagerData)
                    {
                        customManageabilityProvider.AddAdministrativeTemplateDirectives(contentBuilder,
                                                                                        cacheManagerDataBase, configurationSource, cacheManagersKey);
                    }
                    else
                    {
                        String cacheManagerPolicyKey = cacheManagersKey + @"\" + cacheManagerDataBase.Name;

                        contentBuilder.StartPolicy(String.Format(CultureInfo.InvariantCulture,
                                                                 Resources.CacheManagerPolicyNameTemplate,
                                                                 cacheManagerDataBase.Name),
                                                   cacheManagerPolicyKey);
                        {
                            if (cacheManagerDataBase is CacheManagerData)
                            {
                                CacheManagerData cacheManagerData = (CacheManagerData)cacheManagerDataBase;

                                contentBuilder.AddNumericPart(Resources.CacheManagerExpirationPollFrequencyInSecondsPartName,
                                                              CacheManagerExpirationPollFrequencyInSecondsPropertyName,
                                                              cacheManagerData.ExpirationPollFrequencyInSeconds);

                                contentBuilder.AddNumericPart(Resources.CacheManagerMaximumElementsInCacheBeforeScavengingPartName,
                                                              CacheManagerMaximumElementsInCacheBeforeScavengingPropertyName,
                                                              cacheManagerData.MaximumElementsInCacheBeforeScavenging);

                                contentBuilder.AddNumericPart(Resources.CacheManagerNumberToRemoveWhenScavengingPartName,
                                                              CacheManagerNumberToRemoveWhenScavengingPropertyName,
                                                              cacheManagerData.NumberToRemoveWhenScavenging);

                                // append the cache manager's backing store parts
                                contentBuilder.AddTextPart(Resources.BackingStoreSettingsPartName);
                                CacheStorageData backingStoreData
                                    = configurationSection.BackingStores.Get(cacheManagerData.CacheStorage);
                                ConfigurationElementManageabilityProvider backingStoreDataManageablityProvider
                                    = GetSubProvider(backingStoreData.GetType());
                                AddAdministrativeTemplateDirectivesForElement(contentBuilder,
                                                                              backingStoreData, backingStoreDataManageablityProvider,
                                                                              configurationSource,
                                                                              backingStoresKey);

                                // append the backing store's encryption provider parts
                                if (!String.IsNullOrEmpty(backingStoreData.StorageEncryption))
                                {
                                    contentBuilder.AddTextPart(Resources.StorageEncryptionProviderSettingsPartName);
                                    StorageEncryptionProviderData encryptionProviderData
                                        = configurationSection.EncryptionProviders.Get(backingStoreData.StorageEncryption);
                                    ConfigurationElementManageabilityProvider encryptionProviderDataManageabilityProvider
                                        = GetSubProvider(encryptionProviderData.GetType());
                                    AddAdministrativeTemplateDirectivesForElement(contentBuilder,
                                                                                  encryptionProviderData, encryptionProviderDataManageabilityProvider,
                                                                                  configurationSource,
                                                                                  encryptionProvidersKey);
                                }
                            }
                        }
                        contentBuilder.EndPolicy();
                    }
                }
            }
            contentBuilder.EndCategory();
        }
        public void CanAddNumericPartWithKeyNameAndMinMaxValues()
        {
            AdmContentBuilder builder = new AdmContentBuilder();

            builder.StartCategory("category");
            builder.StartPolicy("policy", "key");
            builder.AddNumericPart("part", "key", "value", 150, 100, 200);
            builder.EndPolicy();
            builder.EndCategory();
            AdmContent content = builder.GetContent();

            IEnumerator<AdmCategory> categoriesEnumerator = content.Categories.GetEnumerator();
            categoriesEnumerator.MoveNext();
            IEnumerator<AdmPolicy> policiesEnumerator = categoriesEnumerator.Current.Policies.GetEnumerator();
            policiesEnumerator.MoveNext();
            IEnumerator<AdmPart> partsEnumerator = policiesEnumerator.Current.Parts.GetEnumerator();
            Assert.IsTrue(partsEnumerator.MoveNext());
            Assert.AreSame(typeof(AdmNumericPart), partsEnumerator.Current.GetType());
            Assert.AreEqual("part", ((AdmNumericPart)partsEnumerator.Current).PartName);
            Assert.AreEqual("key", ((AdmNumericPart)partsEnumerator.Current).KeyName);
            Assert.AreEqual("value", ((AdmNumericPart)partsEnumerator.Current).ValueName);
            Assert.AreEqual(150, ((AdmNumericPart)partsEnumerator.Current).DefaultValue);
            Assert.AreEqual(100, ((AdmNumericPart)partsEnumerator.Current).MinValue);
            Assert.AreEqual(200, ((AdmNumericPart)partsEnumerator.Current).MaxValue);
        }
        public void CanAddDropDownListPartForEnumerationWithKeyName()
        {
            AdmContentBuilder builder = new AdmContentBuilder();

            builder.StartCategory("category");
            builder.StartPolicy("policy", "key");
            builder.AddDropDownListPartForEnumeration<UriFormat>("part", "key", "value", UriFormat.UriEscaped);
            builder.EndPolicy();
            builder.EndCategory();
            AdmContent content = builder.GetContent();

            IEnumerator<AdmCategory> categoriesEnumerator = content.Categories.GetEnumerator();
            categoriesEnumerator.MoveNext();
            IEnumerator<AdmPolicy> policiesEnumerator = categoriesEnumerator.Current.Policies.GetEnumerator();
            policiesEnumerator.MoveNext();
            IEnumerator<AdmPart> partsEnumerator = policiesEnumerator.Current.Parts.GetEnumerator();
            Assert.IsTrue(partsEnumerator.MoveNext());
            Assert.AreSame(typeof(AdmDropDownListPart), partsEnumerator.Current.GetType());
            Assert.AreEqual("part", ((AdmDropDownListPart)partsEnumerator.Current).PartName);
            Assert.AreEqual("key", ((AdmDropDownListPart)partsEnumerator.Current).KeyName);
            Assert.AreEqual("value", ((AdmDropDownListPart)partsEnumerator.Current).ValueName);
            Assert.AreEqual(UriFormat.UriEscaped.ToString(), ((AdmDropDownListPart)partsEnumerator.Current).DefaultValue);
            Dictionary<String, String> items = new Dictionary<String, String>();
            foreach (AdmDropDownListItem item in ((AdmDropDownListPart)partsEnumerator.Current).Items)
            {
                items.Add(item.Name, item.Value);
            }
            foreach (String name in Enum.GetNames(typeof(UriFormat)))
            {
                Assert.IsTrue(items.ContainsKey(name));
            }
        }
        public void CanAddDropDownListPartForConfigurationElementsCollectionAllowingNoneAndEmptyDefault()
        {
            NamedElementCollection<NamedConfigurationElement> collection = new NamedElementCollection<NamedConfigurationElement>();
            collection.Add(new NamedConfigurationElement("name1"));
            collection.Add(new NamedConfigurationElement("name2"));
            collection.Add(new NamedConfigurationElement("name3"));

            AdmContentBuilder builder = new AdmContentBuilder();

            builder.StartCategory("category");
            builder.StartPolicy("policy", "key");
            builder.AddDropDownListPartForNamedElementCollection<NamedConfigurationElement>("part", "value", collection, "", true);
            builder.EndPolicy();
            builder.EndCategory();
            AdmContent content = builder.GetContent();

            IEnumerator<AdmCategory> categoriesEnumerator = content.Categories.GetEnumerator();
            categoriesEnumerator.MoveNext();
            IEnumerator<AdmPolicy> policiesEnumerator = categoriesEnumerator.Current.Policies.GetEnumerator();
            policiesEnumerator.MoveNext();
            IEnumerator<AdmPart> partsEnumerator = policiesEnumerator.Current.Parts.GetEnumerator();
            Assert.IsTrue(partsEnumerator.MoveNext());
            Assert.AreSame(typeof(AdmDropDownListPart), partsEnumerator.Current.GetType());
            Assert.AreEqual("part", ((AdmDropDownListPart)partsEnumerator.Current).PartName);
            Assert.AreEqual(null, ((AdmDropDownListPart)partsEnumerator.Current).KeyName);
            Assert.AreEqual("value", ((AdmDropDownListPart)partsEnumerator.Current).ValueName);
            IEnumerator<AdmDropDownListItem> itemsEnumerator = ((AdmDropDownListPart)partsEnumerator.Current).Items.GetEnumerator();
            Assert.IsTrue(itemsEnumerator.MoveNext());
            Assert.AreEqual(AdmContentBuilder.NoneListItem, itemsEnumerator.Current.Value);
            Assert.IsTrue(itemsEnumerator.MoveNext());
            Assert.AreEqual("name1", itemsEnumerator.Current.Name);
            Assert.IsTrue(itemsEnumerator.MoveNext());
            Assert.AreEqual("name2", itemsEnumerator.Current.Name);
            Assert.IsTrue(itemsEnumerator.MoveNext());
            Assert.AreEqual("name3", itemsEnumerator.Current.Name);
            Assert.IsFalse(itemsEnumerator.MoveNext());
        }
        public void CanAddTextPart()
        {
            AdmContentBuilder builder = new AdmContentBuilder();

            builder.StartCategory("category");
            builder.StartPolicy("policy", "key");
            builder.AddTextPart("part");
            builder.EndPolicy();
            builder.EndCategory();
            AdmContent content = builder.GetContent();

            IEnumerator<AdmCategory> categoriesEnumerator = content.Categories.GetEnumerator();
            categoriesEnumerator.MoveNext();
            IEnumerator<AdmPolicy> policiesEnumerator = categoriesEnumerator.Current.Policies.GetEnumerator();
            policiesEnumerator.MoveNext();
            IEnumerator<AdmPart> partsEnumerator = policiesEnumerator.Current.Parts.GetEnumerator();
            Assert.IsTrue(partsEnumerator.MoveNext());
            Assert.AreSame(typeof(AdmTextPart), partsEnumerator.Current.GetType());
            Assert.AreEqual("part", ((AdmTextPart)partsEnumerator.Current).PartName);
        }
        public void CanAddDropDownListPartWithKeyName()
        {
            List<AdmDropDownListItem> items = new List<AdmDropDownListItem>();
            items.Add(new AdmDropDownListItem("1", "1"));
            items.Add(new AdmDropDownListItem("2", "2"));
            items.Add(new AdmDropDownListItem("3", "3"));

            AdmContentBuilder builder = new AdmContentBuilder();

            builder.StartCategory("category");
            builder.StartPolicy("policy", "key");
            builder.AddDropDownListPart("part", "key", "value", items, "1");
            builder.EndPolicy();
            builder.EndCategory();
            AdmContent content = builder.GetContent();

            IEnumerator<AdmCategory> categoriesEnumerator = content.Categories.GetEnumerator();
            categoriesEnumerator.MoveNext();
            IEnumerator<AdmPolicy> policiesEnumerator = categoriesEnumerator.Current.Policies.GetEnumerator();
            policiesEnumerator.MoveNext();
            IEnumerator<AdmPart> partsEnumerator = policiesEnumerator.Current.Parts.GetEnumerator();
            Assert.IsTrue(partsEnumerator.MoveNext());
            Assert.AreSame(typeof(AdmDropDownListPart), partsEnumerator.Current.GetType());
            Assert.AreEqual("part", ((AdmDropDownListPart)partsEnumerator.Current).PartName);
            Assert.AreEqual("key", ((AdmDropDownListPart)partsEnumerator.Current).KeyName);
            Assert.AreEqual("value", ((AdmDropDownListPart)partsEnumerator.Current).ValueName);
            Assert.AreEqual("1", ((AdmDropDownListPart)partsEnumerator.Current).DefaultValue);
            IEnumerator<AdmDropDownListItem> itemsEnumerator = ((AdmDropDownListPart)partsEnumerator.Current).Items.GetEnumerator();
            Assert.IsTrue(itemsEnumerator.MoveNext());
            Assert.AreEqual("1", itemsEnumerator.Current.Name);
            Assert.IsTrue(itemsEnumerator.MoveNext());
            Assert.AreEqual("2", itemsEnumerator.Current.Name);
            Assert.IsTrue(itemsEnumerator.MoveNext());
            Assert.AreEqual("3", itemsEnumerator.Current.Name);
            Assert.IsFalse(itemsEnumerator.MoveNext());
        }
        public void CanAddEditTextPartWithKeyName()
        {
            AdmContentBuilder builder = new AdmContentBuilder();

            builder.StartCategory("category");
            builder.StartPolicy("policy", "key");
            builder.AddEditTextPart("part", "key", "value", "default", 10, true);
            builder.EndPolicy();
            builder.EndCategory();
            AdmContent content = builder.GetContent();

            IEnumerator<AdmCategory> categoriesEnumerator = content.Categories.GetEnumerator();
            categoriesEnumerator.MoveNext();
            IEnumerator<AdmPolicy> policiesEnumerator = categoriesEnumerator.Current.Policies.GetEnumerator();
            policiesEnumerator.MoveNext();
            IEnumerator<AdmPart> partsEnumerator = policiesEnumerator.Current.Parts.GetEnumerator();
            Assert.IsTrue(partsEnumerator.MoveNext());
            Assert.AreSame(typeof(AdmEditTextPart), partsEnumerator.Current.GetType());
            Assert.AreEqual("part", ((AdmEditTextPart)partsEnumerator.Current).PartName);
            Assert.AreEqual("key", ((AdmEditTextPart)partsEnumerator.Current).KeyName);
            Assert.AreEqual("value", ((AdmEditTextPart)partsEnumerator.Current).ValueName);
            Assert.AreEqual("default", ((AdmEditTextPart)partsEnumerator.Current).DefaultValue);
            Assert.AreEqual(10, ((AdmEditTextPart)partsEnumerator.Current).Maxlen);
            Assert.AreEqual(true, ((AdmEditTextPart)partsEnumerator.Current).Required);
        }
        public void CanAddComboBoxPartWithKeyName()
        {
            AdmContentBuilder builder = new AdmContentBuilder();

            builder.StartCategory("category");
            builder.StartPolicy("policy", "key");
            builder.AddComboBoxPart("part", "key", "value", "default", 10, true, "sug1", "sug2");
            builder.EndPolicy();
            builder.EndCategory();
            AdmContent content = builder.GetContent();

            IEnumerator<AdmCategory> categoriesEnumerator = content.Categories.GetEnumerator();
            categoriesEnumerator.MoveNext();
            IEnumerator<AdmPolicy> policiesEnumerator = categoriesEnumerator.Current.Policies.GetEnumerator();
            policiesEnumerator.MoveNext();
            IEnumerator<AdmPart> partsEnumerator = policiesEnumerator.Current.Parts.GetEnumerator();
            Assert.IsTrue(partsEnumerator.MoveNext());
            Assert.AreSame(typeof(AdmComboBoxPart), partsEnumerator.Current.GetType());
            Assert.AreEqual("part", ((AdmComboBoxPart)partsEnumerator.Current).PartName);
            Assert.AreEqual("key", ((AdmComboBoxPart)partsEnumerator.Current).KeyName);
            Assert.AreEqual("value", ((AdmComboBoxPart)partsEnumerator.Current).ValueName);
            Assert.AreEqual("default", ((AdmComboBoxPart)partsEnumerator.Current).DefaultValue);
            //Assert.AreEqual(10, ((AdmComboBoxPart)partsEnumerator.Current).Maxlen);	// because of workaround for GPMC bug
            Assert.AreEqual(true, ((AdmComboBoxPart)partsEnumerator.Current).Required);
            IEnumerator<String> suggestionsEnumerator = ((AdmComboBoxPart)partsEnumerator.Current).Suggestions.GetEnumerator();
            Assert.IsTrue(suggestionsEnumerator.MoveNext());
            Assert.AreEqual("sug1", suggestionsEnumerator.Current);
            Assert.IsTrue(suggestionsEnumerator.MoveNext());
            Assert.AreEqual("sug2", suggestionsEnumerator.Current);
            Assert.IsFalse(suggestionsEnumerator.MoveNext());
        }
        public void CanAddCheckboxPartWithValueOnAndOff()
        {
            AdmContentBuilder builder = new AdmContentBuilder();

            builder.StartCategory("category");
            builder.StartPolicy("policy", "key");
            ;
            builder.AddCheckboxPart("part", "value", true, true, false);
            builder.EndPolicy();
            builder.EndCategory();
            AdmContent content = builder.GetContent();

            IEnumerator<AdmCategory> categoriesEnumerator = content.Categories.GetEnumerator();
            categoriesEnumerator.MoveNext();
            IEnumerator<AdmPolicy> policiesEnumerator = categoriesEnumerator.Current.Policies.GetEnumerator();
            policiesEnumerator.MoveNext();
            IEnumerator<AdmPart> partsEnumerator = policiesEnumerator.Current.Parts.GetEnumerator();
            Assert.IsTrue(partsEnumerator.MoveNext());
            Assert.AreSame(typeof(AdmCheckboxPart), partsEnumerator.Current.GetType());
            Assert.AreEqual("part", ((AdmCheckboxPart)partsEnumerator.Current).PartName);
            Assert.AreEqual(null, ((AdmCheckboxPart)partsEnumerator.Current).KeyName);
            Assert.AreEqual("value", ((AdmCheckboxPart)partsEnumerator.Current).ValueName);
            Assert.AreEqual(true, ((AdmCheckboxPart)partsEnumerator.Current).CheckedByDefault);
            Assert.AreEqual(true, ((AdmCheckboxPart)partsEnumerator.Current).ValueForOn);
            Assert.AreEqual(false, ((AdmCheckboxPart)partsEnumerator.Current).ValueForOff);
        }
        public void CanCreatePolicyInNestedCategory()
        {
            AdmContentBuilder builder = new AdmContentBuilder();

            builder.StartCategory("category");
            builder.StartCategory("subcategory");
            builder.StartPolicy("policy", "key");
            builder.EndPolicy();
            builder.EndCategory();
            builder.EndCategory();
            AdmContent content = builder.GetContent();

            Assert.IsNotNull(content);
            IEnumerator<AdmCategory> categoriesEnumerator = content.Categories.GetEnumerator();
            Assert.IsTrue(categoriesEnumerator.MoveNext());
            Assert.AreEqual("category", categoriesEnumerator.Current.Name);
            IEnumerator<AdmCategory> subCategoriesEnumerator = categoriesEnumerator.Current.Categories.GetEnumerator();
            Assert.IsTrue(subCategoriesEnumerator.MoveNext());
            Assert.AreEqual("subcategory", subCategoriesEnumerator.Current.Name);
            IEnumerator<AdmPolicy> policiesEnumerator = subCategoriesEnumerator.Current.Policies.GetEnumerator();
            Assert.IsTrue(policiesEnumerator.MoveNext());
            Assert.AreEqual("policy", policiesEnumerator.Current.Name);
            Assert.IsFalse(policiesEnumerator.MoveNext());
            Assert.IsFalse(subCategoriesEnumerator.MoveNext());
            Assert.IsFalse(categoriesEnumerator.MoveNext());
        }
        public void CanCreatePolicyInTopLevelCategory()
        {
            AdmContentBuilder builder = new AdmContentBuilder();

            builder.StartCategory("category");
            builder.StartPolicy("policy", "key");
            builder.EndPolicy();
            builder.EndCategory();
            AdmContent content = builder.GetContent();

            Assert.IsNotNull(content);
            IEnumerator<AdmCategory> categoriesEnumerator = content.Categories.GetEnumerator();
            Assert.IsTrue(categoriesEnumerator.MoveNext());
            Assert.AreEqual("category", categoriesEnumerator.Current.Name);
            IEnumerator<AdmPolicy> policiesEnumerator = categoriesEnumerator.Current.Policies.GetEnumerator();
            Assert.IsTrue(policiesEnumerator.MoveNext());
            Assert.AreEqual("policy", policiesEnumerator.Current.Name);
            Assert.AreEqual("key", policiesEnumerator.Current.KeyName);
            Assert.AreEqual(AdmContentBuilder.AvailableValueName, policiesEnumerator.Current.ValueName);
            Assert.IsFalse(policiesEnumerator.MoveNext());
            Assert.IsFalse(categoriesEnumerator.MoveNext());
        }