Esempio n. 1
0
        // Token: 0x060075A8 RID: 30120 RVA: 0x001828DC File Offset: 0x00180ADC
        private ADHealthMonitorConfiguration()
        {
            this.enabled = (this.enabled && Globals.IsMicrosoftHostedOnly);
            ADHealthMonitorConfiguration.Tracer.TraceDebug <bool>((long)this.GetHashCode(), "[ADHealthMonitorConfiguration::ctor] Enabled={0}.", this.enabled);
            if (this.refreshInterval < this.ConfigSettings.DefaultRefreshInterval)
            {
                ADHealthMonitorConfiguration.Tracer.TraceError <TimeSpan, TimeSpan>((long)this.GetHashCode(), "[ADHealthMonitorConfiguration::ctor] Refresh interval '{0}' set in registry is less than '{1}'. Using '{1}' instead.", this.refreshInterval, this.ConfigSettings.DefaultRefreshInterval);
                this.refreshInterval = this.ConfigSettings.DefaultRefreshInterval;
            }
            using (RegistryKey registryKey = ResourceHealthMonitorConfiguration <ADHealthMonitorConfigurationSetting> .OpenConfigurationKey())
            {
                if (registryKey != null)
                {
                    this.overrideHealthMeasure = (registryKey.GetValue(this.ConfigSettings.OverrideHealthMeasureRegistryValueName) as int?);
                    if (this.overrideHealthMeasure > 100 || this.overrideHealthMeasure < -1)
                    {
                        ADHealthMonitorConfiguration.Tracer.TraceError <int?>((long)this.GetHashCode(), "[ADHealthMonitorConfiguration::ctor] OverrideHealthMeasure '{0}' set in registry is not in range [-1, 100]. Using '<null>' instead.", this.overrideHealthMeasure);
                    }
                    ADHealthMonitorConfiguration.Tracer.TraceDebug <string>((long)this.GetHashCode(), "[ADHealthMonitorConfiguration::ctor] OverrideHealthMeasure={0}.", (this.overrideHealthMeasure != null) ? this.overrideHealthMeasure.Value.ToString() : "<null>");
                    this.healthyCutoff = ResourceHealthMonitorConfiguration <ADHealthMonitorConfigurationSetting> .ReadTimeSpan(registryKey, this.ConfigSettings.HealthyCutoffRegistryValueName, this.ConfigSettings.HealthyCutoffDefault);

                    if (this.healthyCutoff < this.refreshInterval)
                    {
                        ADHealthMonitorConfiguration.Tracer.TraceError <TimeSpan, TimeSpan>((long)this.GetHashCode(), "[ADHealthMonitorConfiguration::ctor] Healthy cutoff '{0}' set in registry is less than refresh interval '{1}'. Using '{1}' instead.", this.healthyCutoff, this.refreshInterval);
                        this.healthyCutoff = this.refreshInterval;
                    }
                    ADHealthMonitorConfiguration.Tracer.TraceDebug <TimeSpan>((long)this.GetHashCode(), "[ADHealthMonitorConfiguration::ctor] HealthyCutoff = '{0}'.", this.healthyCutoff);
                    this.fairCutoff = ResourceHealthMonitorConfiguration <ADHealthMonitorConfigurationSetting> .ReadTimeSpan(registryKey, this.ConfigSettings.FairCutoffRegistryValueName, this.ConfigSettings.FairCutoffDefault);

                    if (this.fairCutoff < this.healthyCutoff + this.refreshInterval)
                    {
                        ADHealthMonitorConfiguration.Tracer.TraceError((long)this.GetHashCode(), "[ADHealthMonitorConfiguration::ctor] Fair cutoff '{0}' set in registry is less than healthy cutoff '{1}' plus refresh interval '{2}'. Using '{3}' instead.", new object[]
                        {
                            this.fairCutoff,
                            this.healthyCutoff,
                            this.refreshInterval,
                            this.healthyCutoff + this.refreshInterval
                        });
                        this.fairCutoff = this.healthyCutoff + this.refreshInterval;
                    }
                    ADHealthMonitorConfiguration.Tracer.TraceDebug <TimeSpan>((long)this.GetHashCode(), "[ADHealthMonitorConfiguration::ctor] FairCutoff = '{0}'.", this.fairCutoff);
                }
            }
        }
        protected ResourceHealthMonitorConfiguration()
        {
            this.ConfigSettings  = Activator.CreateInstance <T>();
            this.refreshInterval = this.ConfigSettings.DefaultRefreshInterval;
            using (RegistryKey registryKey = ResourceHealthMonitorConfiguration <T> .OpenConfigurationKey())
            {
                if (registryKey != null)
                {
                    this.enabled = ((int)registryKey.GetValue(this.ConfigSettings.DisabledRegistryValueName, 0) == 0);
                    ResourceHealthMonitorConfiguration <T> .Tracer.TraceDebug <bool>((long)this.GetHashCode(), "[ResourceHealthMonitorConfiguration::ctor] Enabled = '{0}'.", this.enabled);

                    this.refreshInterval = ResourceHealthMonitorConfiguration <T> .ReadTimeSpan(registryKey, this.ConfigSettings.RefreshIntervalRegistryValueName, this.ConfigSettings.DefaultRefreshInterval);

                    ResourceHealthMonitorConfiguration <T> .Tracer.TraceDebug <TimeSpan>((long)this.GetHashCode(), "[ResourceHealthMonitorConfiguration::ctor] RefreshInterval = '{0}'.", this.refreshInterval);

                    this.overrideMetricValue = (registryKey.GetValue(this.ConfigSettings.OverrideMetricValueRegistryValueName) as int?);
                    ResourceHealthMonitorConfiguration <T> .Tracer.TraceDebug <string>((long)this.GetHashCode(), "[ResourceHealthMonitorConfiguration::ctor] OverrideMetricValue = '{0}'.", (this.overrideMetricValue != null)?this.overrideMetricValue.Value.ToString() : "<null>");
                }
            }
        }