/// <summary>
        /// Overrides the <paramref name="configurationObject"/>'s properties with the Group Policy values from the
        /// registry.
        /// </summary>
        /// <param name="configurationObject">The configuration object for instances that must be managed.</param>
        /// <param name="policyKey">The <see cref="IRegistryKey"/> which holds the Group Policy overrides for the
        /// configuration element.</param>
        /// <remarks>Subclasses implementing this method must retrieve all the override values from the registry
        /// before making modifications to the <paramref name="configurationObject"/> so any error retrieving
        /// the override values will cancel policy processing.</remarks>
        protected override void OverrideWithGroupPolicies(RollingFlatFileTraceListenerData configurationObject,
                                                          IRegistryKey policyKey)
        {
            String fileNameOverride  = policyKey.GetStringValue(FileNamePropertyName);
            String formatterOverride = GetFormatterPolicyOverride(policyKey);
            RollFileExistsBehavior?rollFileExistsBehaviorOverride = policyKey.GetEnumValue <RollFileExistsBehavior>(RollFileExistsBehaviorPropertyName);
            RollInterval?          rollIntervalOverride           = policyKey.GetEnumValue <RollInterval>(RollIntervalPropertyName);
            int?         rollSizeKBOverride         = policyKey.GetIntValue(RollSizeKBPropertyName);
            string       timeStampPatternOverride   = policyKey.GetStringValue(TimeStampPatternPropertyName);
            TraceOptions?traceOutputOptionsOverride =
                GetFlagsEnumOverride <TraceOptions>(policyKey, TraceOutputOptionsPropertyName);
            SourceLevels?filterOverride           = policyKey.GetEnumValue <SourceLevels>(FilterPropertyName);
            string       headerOverride           = policyKey.GetStringValue(HeaderPropertyName);
            string       footerOverride           = policyKey.GetStringValue(FooterPropertyName);
            int?         maxArchivedFilesOverride = policyKey.GetIntValue(MaxArchivedFilesPropertyName);

            configurationObject.FileName  = fileNameOverride;
            configurationObject.Header    = headerOverride;
            configurationObject.Footer    = footerOverride;
            configurationObject.Formatter = formatterOverride;
            configurationObject.RollFileExistsBehavior = rollFileExistsBehaviorOverride.Value;
            configurationObject.RollInterval           = rollIntervalOverride.Value;
            configurationObject.RollSizeKB             = rollSizeKBOverride.Value;
            configurationObject.TimeStampPattern       = timeStampPatternOverride;
            configurationObject.TraceOutputOptions     = traceOutputOptionsOverride.Value;
            configurationObject.Filter           = filterOverride.Value;
            configurationObject.MaxArchivedFiles = maxArchivedFilesOverride.Value;
        }
Ejemplo n.º 2
0
        protected override void OverrideWithGroupPolicies(PriorityFilterData configurationObject, IRegistryKey policyKey)
        {
            int?minimumPriorityOverride = policyKey.GetIntValue(MinimumPriorityPropertyName);
            int?maximumPriorityOverride = policyKey.GetIntValue(MaximumPriorityPropertyName);

            configurationObject.MinimumPriority = minimumPriorityOverride.Value;
            configurationObject.MaximumPriority = maximumPriorityOverride.Value;
        }
        protected override void OverrideWithGroupPolicies(CachingStoreProviderData configurationObject, IRegistryKey policyKey)
        {
            String cacheManagerOverride       = policyKey.GetStringValue(CacheManagerPropertyName);
            int?   absoluteExpirationOverride = policyKey.GetIntValue(AbsoluteExpirationPropertyName);
            int?   slidingExpirationOverride  = policyKey.GetIntValue(SlidingExpirationPropertyName);

            configurationObject.CacheManager       = cacheManagerOverride;
            configurationObject.AbsoluteExpiration = absoluteExpirationOverride.Value;
            configurationObject.SlidingExpiration  = slidingExpirationOverride.Value;
        }
        bool OverrideWithGroupPoliciesAndGenerateWmiObjectsForCacheManager(CacheManagerDataBase cacheManagerDataBase,
                                                                           bool readGroupPolicies,
                                                                           IRegistryKey machineKey,
                                                                           IRegistryKey userKey,
                                                                           bool generateWmiObjects,
                                                                           ICollection <ConfigurationSetting> wmiSettings)
        {
            if (readGroupPolicies)
            {
                IRegistryKey policyKey = machineKey != null ? machineKey : userKey;
                if (policyKey != null)
                {
                    if (policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value)
                    {
                        return(false);
                    }
                    try
                    {
                        if (cacheManagerDataBase is CacheManagerData)
                        {
                            CacheManagerData cacheManagerData = (CacheManagerData)cacheManagerDataBase;

                            // cache storage is not overrideable
                            int?expirationPollFrequencyInSecondsOverride
                                = policyKey.GetIntValue(CacheManagerExpirationPollFrequencyInSecondsPropertyName);
                            int?maximumElementsInCacheBeforeScavengingOverride
                                = policyKey.GetIntValue(CacheManagerMaximumElementsInCacheBeforeScavengingPropertyName);
                            int?numberToRemoveWhenScavengingOverride
                                = policyKey.GetIntValue(CacheManagerNumberToRemoveWhenScavengingPropertyName);

                            cacheManagerData.ExpirationPollFrequencyInSeconds       = expirationPollFrequencyInSecondsOverride.Value;
                            cacheManagerData.MaximumElementsInCacheBeforeScavenging = maximumElementsInCacheBeforeScavengingOverride.Value;
                            cacheManagerData.NumberToRemoveWhenScavenging           = numberToRemoveWhenScavengingOverride.Value;
                        }
                    }
                    catch (RegistryAccessException ex)
                    {
                        LogExceptionWhileOverriding(ex);
                    }
                }
            }
            if (generateWmiObjects)
            {
                CacheManagerSettingsWmiMapper.GenerateCacheManagerWmiObjects(cacheManagerDataBase, wmiSettings);
            }

            return(true);
        }
        /// <summary>
        /// Overrides the <paramref name="configurationObject"/>'s properties with the Group Policy values from the
        /// registry.
        /// </summary>
        /// <param name="configurationObject">The configuration object for instances that must be managed.</param>
        /// <param name="policyKey">The <see cref="IRegistryKey"/> which holds the Group Policy overrides for the
        /// configuration element.</param>
        /// <remarks>Subclasses implementing this method must retrieve all the override values from the registry
        /// before making modifications to the <paramref name="configurationObject"/> so any error retrieving
        /// the override values will cancel policy processing.</remarks>
        protected override void OverrideWithGroupPolicies(LoggingExceptionHandlerData configurationObject, IRegistryKey policyKey)
        {
            int?           eventIdOverride       = policyKey.GetIntValue(EventIdPropertyName);
            Type           formatterTypeOverride = policyKey.GetTypeValue(FormatterTypePropertyName);
            String         logCategoryOverride   = policyKey.GetStringValue(LogCategoryPropertyName);
            int?           priorityOverride      = policyKey.GetIntValue(PriorityPropertyName);
            TraceEventType?severityOverride      = policyKey.GetEnumValue <TraceEventType>(SeverityPropertyName);
            String         titleOverride         = policyKey.GetStringValue(TitlePropertyName);

            configurationObject.EventId       = eventIdOverride.Value;
            configurationObject.FormatterType = formatterTypeOverride;
            configurationObject.LogCategory   = logCategoryOverride;
            configurationObject.Priority      = priorityOverride.Value;
            configurationObject.Severity      = severityOverride.Value;
            configurationObject.Title         = titleOverride;
        }
Ejemplo n.º 6
0
        protected override void OverrideWithGroupPolicies(RollOnceTraceListenerData configObj,
                                                          IRegistryKey policyKey)
        {
            string filenameOverride = policyKey.GetStringValue(FilenamePropertyName);
            string headerOverride   = policyKey.GetStringValue(HeaderPropertyName);
            string footerOverride   = policyKey.GetStringValue(FooterPropertyName);
            int?   maxLogs          = policyKey.GetIntValue(MaxLogsPropertyName);

            string       formatterOverride   = GetFormatterPolicyOverride(policyKey);
            TraceOptions?traceOutputOptionsO = policyKey.GetEnumValue <TraceOptions>(TraceOutputOptionsPropertyName);
            SourceLevels?filterOverride      = policyKey.GetEnumValue <SourceLevels>(FilterPropertyName);

            configObj.FileName           = filenameOverride;
            configObj.Header             = headerOverride;
            configObj.Footer             = footerOverride;
            configObj.Formatter          = formatterOverride;
            configObj.MaxLogs            = maxLogs.Value;
            configObj.TraceOutputOptions = traceOutputOptionsO.Value;
            configObj.Filter             = filterOverride.Value;
        }
        protected override void OverrideWithGroupPolicies(EmailTraceListenerData configurationObject, IRegistryKey policyKey)
        {
            String       formatterOverride          = GetFormatterPolicyOverride(policyKey);
            String       fromAddressOverride        = policyKey.GetStringValue(FromAddressPropertyName);
            int?         smtpPortOverride           = policyKey.GetIntValue(SmtpPortPropertyName);
            String       smtpServerOverride         = policyKey.GetStringValue(SmtpServerPropertyName);
            String       subjectLineEnderOverride   = policyKey.GetStringValue(SubjectLineEnderPropertyName);
            String       subjectLineStarterOverride = policyKey.GetStringValue(SubjectLineStarterPropertyName);
            String       toAddressOverride          = policyKey.GetStringValue(ToAddressPropertyName);
            TraceOptions?traceOutputOptionsOverride = policyKey.GetEnumValue <TraceOptions>(TraceOutputOptionsPropertyName);

            configurationObject.Formatter          = formatterOverride;
            configurationObject.FromAddress        = fromAddressOverride;
            configurationObject.SmtpPort           = smtpPortOverride.Value;
            configurationObject.SmtpServer         = smtpServerOverride;
            configurationObject.SubjectLineEnder   = subjectLineEnderOverride;
            configurationObject.SubjectLineStarter = subjectLineStarterOverride;
            configurationObject.ToAddress          = toAddressOverride;
            configurationObject.TraceOutputOptions = traceOutputOptionsOverride.Value;
        }