Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
 private static uint GetUIntValue(OwaRegistryKey key)
 {
     return(OwaRegistryKeys.GetValue <uint>(key));
 }
Ejemplo n.º 4
0
 private static bool GetBoolValue(OwaRegistryKey key)
 {
     return(OwaRegistryKeys.GetValue <bool>(key));
 }
Ejemplo n.º 5
0
 private static string GetStringValue(OwaRegistryKey key)
 {
     return(OwaRegistryKeys.GetValue <string>(key));
 }