コード例 #1
0
ファイル: Globals.cs プロジェクト: YHZX2013/exchange_diff
        internal static T GetEnumValueFromRegistry <T>(string registryPath, string valueName, T defaultValue, Microsoft.Exchange.Diagnostics.Trace tracer) where T : struct
        {
            string valueFromRegistry = Globals.GetValueFromRegistry <string>(registryPath, valueName, defaultValue.ToString(), tracer);
            T      result;

            if (Enum.TryParse <T>(valueFromRegistry, out result))
            {
                tracer.TraceDebug <string, string>(0L, "Using enum {0} = {1} (from registry)", valueName, valueFromRegistry);
                return(result);
            }
            tracer.TraceError <string, string, T>(0L, "{0} has wrong enum value: {1}, using {2}.", valueName, valueFromRegistry, defaultValue);
            return(defaultValue);
        }
コード例 #2
0
ファイル: Globals.cs プロジェクト: YHZX2013/exchange_diff
        internal static T GetValueFromRegistry <T>(string registryPath, string valueName, T defaultValue, Microsoft.Exchange.Diagnostics.Trace tracer)
        {
            T result = defaultValue;

            try
            {
                using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(registryPath, false))
                {
                    if (registryKey != null)
                    {
                        object value = registryKey.GetValue(valueName, defaultValue);
                        if (value is T)
                        {
                            tracer.TraceDebug <string, object>(0L, "Using {0} = {1} (from registry)", valueName, value);
                            result = (T)((object)value);
                        }
                        else
                        {
                            tracer.TraceError <string, string, T>(0L, "{0} has wrong type {1}, using {2}.", valueName, (value == null) ? "<undefined>" : value.GetType().Name, defaultValue);
                        }
                    }
                    else
                    {
                        tracer.TraceError <string, T>(0L, "Opening registry key {0} failed, using {1}.", valueName, defaultValue);
                    }
                }
            }
            catch (SecurityException ex)
            {
                tracer.TraceError <string>(0L, "SecurityException: {0}", ex.Message);
            }
            catch (UnauthorizedAccessException ex2)
            {
                tracer.TraceError <string>(0L, "UnauthorizedAccessException: {0}", ex2.Message);
            }
            return(result);
        }
コード例 #3
0
 // Token: 0x0600003F RID: 63 RVA: 0x00003070 File Offset: 0x00001270
 internal static void TraceError(Microsoft.Exchange.Diagnostics.Trace trace, string formatString, params object[] args)
 {
     trace.TraceError(0L, formatString + Logger.appDomainTraceInfo, args);
 }
コード例 #4
0
 private void TraceAndLogError(Microsoft.Exchange.Diagnostics.Trace tracer, string format, params object[] parameters)
 {
     tracer.TraceError((long)this.GetHashCode(), format, parameters);
     this.log.Log(DiagnosticsAggregationEvent.ServiceletError, format, parameters);
 }