예제 #1
0
        private static T GetValue <T>(OwaRegistryKey key)
        {
            object obj = null;

            if (OwaRegistryKeys.keyValueCache.TryGetValue(key, out obj))
            {
                return((T)((object)obj));
            }
            return((T)((object)key.DefaultValue));
        }
예제 #2
0
        private static object ReadKeyValue(RegistryKey keyContainer, OwaRegistryKey owaKey)
        {
            ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "Reading registry key \"{0}\"", owaKey.Name);
            object obj;

            if (owaKey.KeyType == typeof(int))
            {
                obj = keyContainer.GetValue(owaKey.Name, owaKey.DefaultValue);
                if (obj.GetType() != typeof(int))
                {
                    obj = null;
                }
            }
            else if (owaKey.KeyType == typeof(uint))
            {
                obj = keyContainer.GetValue(owaKey.Name, owaKey.DefaultValue);
                if (obj.GetType() != typeof(uint))
                {
                    obj = null;
                }
            }
            else if (owaKey.KeyType == typeof(string))
            {
                obj = keyContainer.GetValue(owaKey.Name, owaKey.DefaultValue);
                if (obj.GetType() != typeof(string))
                {
                    obj = null;
                }
            }
            else
            {
                if (!(owaKey.KeyType == typeof(bool)))
                {
                    return(null);
                }
                object value = keyContainer.GetValue(owaKey.Name, owaKey.DefaultValue);
                if (value.GetType() != typeof(int))
                {
                    obj = null;
                }
                else
                {
                    obj = ((int)value != 0);
                }
            }
            if (obj == null)
            {
                ExTraceGlobals.CoreTracer.TraceDebug(0L, "Couldn't find key or key format/type was incorrect, using default value");
                obj = owaKey.DefaultValue;
            }
            ExTraceGlobals.CoreTracer.TraceDebug <string, object>(0L, "Configuration registry key \"{0}\" read with value=\"{1}\"", owaKey.Name, obj);
            return(obj);
        }
예제 #3
0
 private static uint GetUIntValue(OwaRegistryKey key)
 {
     return(OwaRegistryKeys.GetValue <uint>(key));
 }
예제 #4
0
 private static bool GetBoolValue(OwaRegistryKey key)
 {
     return(OwaRegistryKeys.GetValue <bool>(key));
 }
예제 #5
0
 private static string GetStringValue(OwaRegistryKey key)
 {
     return(OwaRegistryKeys.GetValue <string>(key));
 }