/// <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, MsmqTraceListenerData configurationObject, IConfigurationSource configurationSource, String elementPolicyKeyName) { contentBuilder.AddEditTextPart(Resources.MsmqTraceListenerQueuePathPartName, QueuePathPropertyName, configurationObject.QueuePath, 255, true); contentBuilder.AddDropDownListPartForEnumeration <MessagePriority>(Resources.MsmqTraceListenerPriorityPartName, MessagePriorityPropertyName, configurationObject.MessagePriority); contentBuilder.AddEditTextPart(Resources.MsmqTraceListenerTtbrPartName, TimeToBeReceivedPropertyName, Convert.ToString(configurationObject.TimeToBeReceived, CultureInfo.InvariantCulture), 255, false); contentBuilder.AddEditTextPart(Resources.MsmqTraceListenerTtrqPartName, TimeToReachQueuePropertyName, Convert.ToString(configurationObject.TimeToReachQueue, CultureInfo.InvariantCulture), 255, false); contentBuilder.AddCheckboxPart(Resources.MsmqTraceListenerRecoverablePartName, RecoverablePropertyName, configurationObject.Recoverable); contentBuilder.AddDropDownListPartForEnumeration <MessageQueueTransactionType>(Resources.MsmqTraceListenerTransactionTypePartName, TransactionTypePropertyName, configurationObject.TransactionType); contentBuilder.AddCheckboxPart(Resources.MsmqTraceListenerUseAuthenticationPartName, UseAuthenticationPropertyName, configurationObject.UseAuthentication); contentBuilder.AddCheckboxPart(Resources.MsmqTraceListenerUseDeadLetterQueuePartName, UseDeadLetterQueuePropertyName, configurationObject.UseDeadLetterQueue); contentBuilder.AddCheckboxPart(Resources.MsmqTraceListenerUseEncryptionPartName, UseEncryptionPropertyName, configurationObject.UseEncryption); AddTraceOptionsPart(contentBuilder, elementPolicyKeyName, configurationObject.TraceOutputOptions); AddFilterPart(contentBuilder, configurationObject.Filter); AddFormattersPart(contentBuilder, configurationObject.Formatter, configurationSource); }
/// <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, RollingFlatFileTraceListenerData configurationObject, IConfigurationSource configurationSource, String elementPolicyKeyName) { contentBuilder.AddEditTextPart(Resources.RollingFlatFileTraceListenerFileNamePartName, FileNamePropertyName, configurationObject.FileName, 255, true); contentBuilder.AddEditTextPart(Resources.FlatFileTraceListenerHeaderPartName, HeaderPropertyName, configurationObject.Header, 512, false); contentBuilder.AddEditTextPart(Resources.FlatFileTraceListenerFooterPartName, FooterPropertyName, configurationObject.Footer, 512, false); contentBuilder.AddDropDownListPartForEnumeration <RollFileExistsBehavior>(Resources.RollingFlatFileTraceListenerRollFileExistsBehaviorPartName, RollFileExistsBehaviorPropertyName, configurationObject.RollFileExistsBehavior); contentBuilder.AddDropDownListPartForEnumeration <RollInterval>(Resources.RollingFlatFileTraceListenerRollIntervalPartName, RollIntervalPropertyName, configurationObject.RollInterval); contentBuilder.AddNumericPart(Resources.RollingFlatFileTraceListenerRollSizeKBPartName, RollSizeKBPropertyName, configurationObject.RollSizeKB); contentBuilder.AddEditTextPart(Resources.RollingFlatFileTraceListenerTimeStampPatternPartName, TimeStampPatternPropertyName, configurationObject.TimeStampPattern, 512, true); contentBuilder.AddNumericPart(Resources.RollingFlatFileTraceListenerMaxArchivedFilesPartName, MaxArchivedFilesPropertyName, configurationObject.MaxArchivedFiles); AddTraceOptionsPart(contentBuilder, elementPolicyKeyName, configurationObject.TraceOutputOptions); AddFilterPart(contentBuilder, configurationObject.Filter); AddFormattersPart(contentBuilder, configurationObject.Formatter, configurationSource); }
protected internal static void AddFilterPart(AdmContentBuilder contentBuilder, SourceLevels filter) { contentBuilder.AddDropDownListPartForEnumeration <SourceLevels>(Resources.TraceListenerFilterPartName, FilterPropertyName, filter); }
protected internal static void AddTraceOptionsPart(AdmContentBuilder contentBuilder, TraceOptions traceOutputOptions) { contentBuilder.AddDropDownListPartForEnumeration <TraceOptions>(Resources.TraceListenerTraceOptionsPartName, TraceOutputOptionsPropertyName, traceOutputOptions); }
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(); }
/// <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); } }
/// <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 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, DpapiSymmetricCryptoProviderData configurationObject, IConfigurationSource configurationSource, String elementPolicyKeyName) { contentBuilder.AddDropDownListPartForEnumeration(Resources.DpapiSymmetricProviderScopePartName, ScopePropertyName, configurationObject.Scope); }
/// <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); }
protected override void AddElementAdministrativeTemplateParts(AdmContentBuilder contentBuilder, SymmetricAlgorithmProviderData configurationObject, IConfigurationSource configurationSource, String elementPolicyKeyName) { contentBuilder.AddEditTextPart(Resources.SymmetricAlgorithmProviderKeyFileNamePartName, ProtectedKeyFilenamePropertyName, configurationObject.ProtectedKeyFilename, 255, true); contentBuilder.AddDropDownListPartForEnumeration <DataProtectionScope>(Resources.SymmetricAlgorithmProviderKeyProtectionScopePartName, ProtectedKeyProtectionScopePropertyName, configurationObject.ProtectedKeyProtectionScope); }
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.AddDropDownListPartForEnumeration <TraceOptions>(Resources.TraceListenerTraceOptionsPartName, TraceOutputOptionsPropertyName, configurationObject.TraceOutputOptions); }
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)); } }