/// <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);
        }
        /// <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);
        }
Exemplo n.º 3
0
        // adds the admin parts that represent the properties of a
        // specific instance of the config element type managed by the reciever.
        //
        protected override void AddElementAdministrativeTemplateParts(AdmContentBuilder contentBuilder,
                                                                      RollOnceTraceListenerData configObj,
                                                                      IConfigurationSource configSource,
                                                                      string elementPolicyKeyName)
        {
            /* uses resources for these parts... */
            contentBuilder.AddEditTextPart("Filename",
                                           FilenamePropertyName,
                                           configObj.FileName,
                                           255,
                                           true);
            contentBuilder.AddEditTextPart("Header",
                                           HeaderPropertyName,
                                           configObj.Header,
                                           512,
                                           false);
            contentBuilder.AddEditTextPart("Footer",
                                           FooterPropertyName,
                                           configObj.Footer,
                                           512,
                                           false);
            contentBuilder.AddNumericPart("Max Logs",
                                          MaxLogsPropertyName,
                                          configObj.MaxLogs);

            AddTraceOptionsPart(contentBuilder, configObj.TraceOutputOptions);
            AddFilterPart(contentBuilder, configObj.Filter);
            AddFormattersPart(contentBuilder, configObj.Formatter, configSource);
        }
 protected override void AddElementAdministrativeTemplateParts(AdmContentBuilder contentBuilder,
                                                               PriorityFilterData configurationObject,
                                                               IConfigurationSource configurationSource,
                                                               String elementPolicyKeyName)
 {
     contentBuilder.AddNumericPart(Resources.PriorityFilterMaximumPriorityPartName,
                                   null,
                                   MaximumPriorityPropertyName,
                                   configurationObject.MaximumPriority,
                                   0,
                                   999999999);
     contentBuilder.AddNumericPart(Resources.PriorityFilterMinimumPriorityPartName,
                                   null,
                                   MinimumPriorityPropertyName,
                                   configurationObject.MinimumPriority,
                                   0,
                                   999999999);
 }
        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);
        }
        /// <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,
                                                                      EmailTraceListenerData configurationObject,
                                                                      IConfigurationSource configurationSource,
                                                                      String elementPolicyKeyName)
        {
            contentBuilder.AddEditTextPart(Resources.EmailTraceListenerFromAddressPartName,
                                           FromAddressPropertyName,
                                           configurationObject.FromAddress,
                                           255,
                                           true);

            contentBuilder.AddEditTextPart(Resources.EmailTraceListenerToAddressPartName,
                                           ToAddressPropertyName,
                                           configurationObject.ToAddress,
                                           255,
                                           false);

            contentBuilder.AddNumericPart(Resources.EmailTraceListenerSmtpPortPartName,
                                          SmtpPortPropertyName,
                                          configurationObject.SmtpPort);

            contentBuilder.AddEditTextPart(Resources.EmailTraceListenerSmtpServerPartName,
                                           SmtpServerPropertyName,
                                           configurationObject.SmtpServer,
                                           255,
                                           true);

            contentBuilder.AddEditTextPart(Resources.EmailTraceListenerStarterPartName,
                                           SubjectLineStarterPropertyName,
                                           configurationObject.SubjectLineStarter,
                                           255,
                                           false);

            contentBuilder.AddEditTextPart(Resources.EmailTraceListenerEnderPartName,
                                           SubjectLineEnderPropertyName,
                                           configurationObject.SubjectLineEnder,
                                           255,
                                           false);

            AddTraceOptionsPart(contentBuilder, elementPolicyKeyName, configurationObject.TraceOutputOptions);

            AddFilterPart(contentBuilder, configurationObject.Filter);

            AddFormattersPart(contentBuilder, configurationObject.Formatter, configurationSource);
        }
        public void AddNumericPartWithDefaultValueAboveMinMaxRangeThrows()
        {
            AdmContentBuilder builder = new AdmContentBuilder();

            builder.StartCategory("category");
            builder.StartPolicy("policy", "key");
            builder.AddNumericPart("part", "key", "value", 10, 2, 4);
        }
        public void AddNumericPartWithMaxValueBelowMinValueThrows()
        {
            AdmContentBuilder builder = new AdmContentBuilder();

            builder.StartCategory("category");
            builder.StartPolicy("policy", "key");
            builder.AddNumericPart("part", "key", "value", 10, 5, 4);
        }
        public void AddNumericPartWithMaxValueAboveValidRangeThrows()
        {
            AdmContentBuilder builder = new AdmContentBuilder();

            builder.StartCategory("category");
            builder.StartPolicy("policy", "key");
            builder.AddNumericPart("part", "key", "value", 10, 1, 1000000000);
        }
        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);
        }
        /// <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();
        }