Beispiel #1
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);
        }
Beispiel #2
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);
        }
        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();
        }
Beispiel #4
0
        protected internal static void AddFormattersPart(AdmContentBuilder contentBuilder,
                                                         String formatterName,
                                                         IConfigurationSource configurationSource)
        {
            LoggingSettings configurationSection = (LoggingSettings)configurationSource.GetSection(LoggingSettings.SectionName);

            contentBuilder.AddDropDownListPartForNamedElementCollection <FormatterData>(Resources.TraceListenerFormatterPartName,
                                                                                        FormatterPropertyName,
                                                                                        configurationSection.Formatters,
                                                                                        formatterName,
                                                                                        true);
        }
        /// <summary>
        /// Adds the ADM parts that represent 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>
        /// Subclasses managing objects that must not create a policy will likely need to include the elements' keys when creating the parts.
        /// </remarks>
        protected override void AddElementAdministrativeTemplateParts(AdmContentBuilder contentBuilder,
                                                                      LoggingExceptionHandlerData configurationObject,
                                                                      IConfigurationSource configurationSource,
                                                                      String elementPolicyKeyName)
        {
            contentBuilder.AddTextPart(String.Format(CultureInfo.CurrentCulture,
                                                     Resources.HandlerPartNameTemplate,
                                                     configurationObject.Name));

            contentBuilder.AddEditTextPart(Resources.LoggingHandlerTitlePartName,
                                           elementPolicyKeyName,
                                           TitlePropertyName,
                                           configurationObject.Title,
                                           255,
                                           true);

            contentBuilder.AddNumericPart(Resources.LoggingHandlerEventIdPartName,
                                          elementPolicyKeyName,
                                          EventIdPropertyName,
                                          configurationObject.EventId);

            contentBuilder.AddDropDownListPartForEnumeration <TraceEventType>(Resources.LoggingHandlerSeverityPartName,
                                                                              elementPolicyKeyName,
                                                                              SeverityPropertyName,
                                                                              configurationObject.Severity);

            contentBuilder.AddNumericPart(Resources.LoggingHandlerPriorityPartName,
                                          elementPolicyKeyName,
                                          PriorityPropertyName,
                                          configurationObject.Priority);

            LoggingSettings loggingConfigurationSection
                = configurationSource.GetSection(LoggingSettings.SectionName) as LoggingSettings;

            contentBuilder.AddDropDownListPartForNamedElementCollection <TraceSourceData>(Resources.LoggingHandlerCategoryPartName,
                                                                                          elementPolicyKeyName,
                                                                                          LogCategoryPropertyName,
                                                                                          loggingConfigurationSection.TraceSources,
                                                                                          configurationObject.LogCategory,
                                                                                          false);

            contentBuilder.AddComboBoxPart(Resources.LoggingHandlerFormatterPartName,
                                           elementPolicyKeyName,
                                           FormatterTypePropertyName,
                                           configurationObject.FormatterType.AssemblyQualifiedName,
                                           255,
                                           true,
                                           typeof(TextExceptionFormatter).AssemblyQualifiedName,
                                           typeof(XmlExceptionFormatter).AssemblyQualifiedName);
        }
 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();
 }
        protected override void AddElementAdministrativeTemplateParts(AdmContentBuilder contentBuilder,
                                                                      SymmetricStorageEncryptionProviderData configurationObject,
                                                                      IConfigurationSource configurationSource,
                                                                      String elementPolicyKeyName)
        {
            CryptographySettings cryptographySection
                = configurationSource.GetSection("securityCryptographyConfiguration") as CryptographySettings;

            contentBuilder.AddDropDownListPartForNamedElementCollection <SymmetricProviderData>(Resources.SymmetricStorageEncryptionProviderSymmetricInstancePartName,
                                                                                                elementPolicyKeyName,
                                                                                                SymmetricInstancePropertyName,
                                                                                                cryptographySection.SymmetricCryptoProviders,
                                                                                                configurationObject.SymmetricInstance,
                                                                                                false);
        }
        protected override void AddElementAdministrativeTemplateParts(AdmContentBuilder contentBuilder,
                                                                      CustomTraceListenerData configurationObject,
                                                                      IConfigurationSource configurationSource,
                                                                      String elementPolicyKeyName)
        {
            base.AddElementAdministrativeTemplateParts(contentBuilder,
                                                       configurationObject,
                                                       configurationSource,
                                                       elementPolicyKeyName);
            LoggingSettings configurationSection = (LoggingSettings)configurationSource.GetSection(LoggingSettings.SectionName);

            contentBuilder.AddDropDownListPartForNamedElementCollection <FormatterData>(Resources.TraceListenerFormatterPartName,
                                                                                        FormatterPropertyName,
                                                                                        configurationSection.Formatters,
                                                                                        configurationObject.Formatter,
                                                                                        true);
        }
        protected override void AddElementAdministrativeTemplateParts(AdmContentBuilder contentBuilder,
                                                                      CachingStoreProviderData configurationObject,
                                                                      IConfigurationSource configurationSource,
                                                                      String elementPolicyKeyName)
        {
            CacheManagerSettings cachingConfigurationSection
                = (CacheManagerSettings)configurationSource.GetSection(CacheManagerSettings.SectionName);

            contentBuilder.AddDropDownListPartForNamedElementCollection <CacheManagerData>(Resources.CachingStoreProviderCacheManagerPartName,
                                                                                           CacheManagerPropertyName,
                                                                                           cachingConfigurationSection.CacheManagers,
                                                                                           configurationObject.CacheManager,
                                                                                           false);

            contentBuilder.AddNumericPart(Resources.CachingStoreProviderAbsoluteExpirationPartName,
                                          AbsoluteExpirationPropertyName,
                                          configurationObject.AbsoluteExpiration);

            contentBuilder.AddNumericPart(Resources.CachingStoreProviderSlidingExpirationPartName,
                                          SlidingExpirationPropertyName,
                                          configurationObject.SlidingExpiration);
        }
        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());
        }