protected override void AddElementAdministrativeTemplateParts(AdmContentBuilder contentBuilder, TextFormatterData configurationObject, IConfigurationSource configurationSource, String elementPolicyKeyName) { contentBuilder.AddEditTextPart(Resources.TextFormatterTemplatePartName, TemplatePropertyName, "", 1024, true); contentBuilder.AddTextPart(Resources.TextFormatterEscapeInstructions_1); contentBuilder.AddTextPart(Resources.TextFormatterEscapeInstructions_2); }
/// <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, FaultContractExceptionHandlerData configurationObject, IConfigurationSource configurationSource, String elementPolicyKeyName) { contentBuilder.AddTextPart(String.Format(CultureInfo.CurrentCulture, Resources.HandlerPartNameTemplate, configurationObject.Name)); contentBuilder.AddEditTextPart(Resources.FaultContractExceptionHandlerExceptionMessagePartName, elementPolicyKeyName, ExceptionMessagePropertyName, configurationObject.ExceptionMessage, 512, true); contentBuilder.AddEditTextPart(Resources.FaultContractExceptionHandlerFaultContractTypePartName, elementPolicyKeyName, FaultContractTypePropertyName, configurationObject.FaultContractType, 512, true); contentBuilder.AddEditTextPart(Resources.FaultContractExceptionHandlerAttributesPartName, elementPolicyKeyName, AttributesPropertyName, GenerateAttributesString(configurationObject.Attributes), 1024, false); }
/// <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, CategoryFilterData configurationObject, IConfigurationSource configurationSource, String elementPolicyKeyName) { contentBuilder.AddDropDownListPartForEnumeration <CategoryFilterMode>(Resources.CategoryFilterFilterModePartName, CategoryFilterModePropertyName, configurationObject.CategoryFilterMode); contentBuilder.AddTextPart(Resources.CategoryFilterCategoriesPartName); LoggingSettings configurationSection = configurationSource.GetSection(LoggingSettings.SectionName) as LoggingSettings; String logFilterCategoriesKeyName = elementPolicyKeyName + @"\" + CategoryFiltersKeyName; foreach (TraceSourceData category in configurationSection.TraceSources) { contentBuilder.AddCheckboxPart(category.Name, logFilterCategoriesKeyName, category.Name, configurationObject.CategoryFilters.Contains(category.Name), true, false); } }
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(); }
protected override void AddElementAdministrativeTemplateParts(AdmContentBuilder contentBuilder, CacheStorageData configurationObject, IConfigurationSource configurationSource, String elementPolicyKeyName) { contentBuilder.AddTextPart(Resources.NullBackingStoreNoSettingsPartName); }
/// <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 that manage custom provider's configuration objects with additional properties may /// override this method to add the corresponding parts. /// </remarks> /// <seealso cref="ConfigurationElementManageabilityProviderBase{T}.AddAdministrativeTemplateDirectives(AdmContentBuilder, T, IConfigurationSource, String)"/> protected override void AddElementAdministrativeTemplateParts( AdmContentBuilder contentBuilder, T configurationObject, IConfigurationSource configurationSource, string elementPolicyKeyName) { base.AddElementAdministrativeTemplateParts(contentBuilder, configurationObject, configurationSource, elementPolicyKeyName); contentBuilder.AddEditTextPart(Resources.CustomTraceListenerInitializationPartName, InitDataPropertyName, configurationObject.InitData, 1024, false); contentBuilder.AddTextPart(Resources.TraceListenerTraceOptionsPartName); var traceOptionsKey = elementPolicyKeyName + @"\" + TraceOutputOptionsPropertyName; AddCheckboxPartsForFlagsEnumeration <TraceOptions>(contentBuilder, traceOptionsKey, configurationObject.TraceOutputOptions); contentBuilder.AddDropDownListPartForEnumeration <SourceLevels>(Resources.TraceListenerFilterPartName, FilterPropertyName, configurationObject.Filter); }
/// <summary> /// Adds the part to edit the policy overrides for the trace options of a trace listener to the content /// built by the <paramref name="contentBuilder"/>. /// </summary> /// <param name="contentBuilder">The builder for the content where the part will be added.</param> /// <param name="parentKey"></param> /// <param name="traceOutputOptions">The default value for the part.</param> protected internal static void AddTraceOptionsPart(AdmContentBuilder contentBuilder, string parentKey, TraceOptions traceOutputOptions) { contentBuilder.AddTextPart(Resources.TraceListenerTraceOptionsPartName); var traceOptionsKey = parentKey + @"\" + TraceOutputOptionsPropertyName; AddCheckboxPartsForFlagsEnumeration <TraceOptions>(contentBuilder, traceOptionsKey, traceOutputOptions); }
/// <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(); } }
/// <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); }
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 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(); } }
protected override void AddElementAdministrativeTemplateParts(AdmContentBuilder contentBuilder, CustomHandlerData configurationObject, IConfigurationSource configurationSource, String elementPolicyKeyName) { contentBuilder.AddTextPart(String.Format(CultureInfo.CurrentCulture, Resources.HandlerPartNameTemplate, configurationObject.Name)); contentBuilder.AddEditTextPart(Resources.CustomHandlerTypePartName, elementPolicyKeyName, ProviderTypePropertyName, configurationObject.Type.AssemblyQualifiedName, 1024, true); contentBuilder.AddEditTextPart(Resources.CustomHandlerAttributesPartName, elementPolicyKeyName, AttributesPropertyName, GenerateAttributesString(configurationObject.Attributes), 1024, false); }
protected override void AddElementAdministrativeTemplateParts(AdmContentBuilder contentBuilder, ReplaceHandlerData configurationObject, IConfigurationSource configurationSource, String elementPolicyKeyName) { contentBuilder.AddTextPart(String.Format(CultureInfo.CurrentCulture, Resources.HandlerPartNameTemplate, configurationObject.Name)); contentBuilder.AddEditTextPart(Resources.ReplaceHandlerExceptionMessagePartName, elementPolicyKeyName, ExceptionMessagePropertyName, configurationObject.ExceptionMessage, 1024, true); contentBuilder.AddEditTextPart(Resources.ReplaceHandlerExceptionTypePartName, elementPolicyKeyName, ReplaceExceptionTypePropertyName, configurationObject.ReplaceExceptionType.AssemblyQualifiedName, 1024, true); }
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); }
/// <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(); }