예제 #1
0
        protected override bool OnTryGet(SettingsHive hive, string name, out string value)
        {
            object sync = base.Sync;

            lock (sync)
            {
                return(this.GetHive(hive).TryGetValue(name, out value));
            }
        }
예제 #2
0
        public bool Remove(SettingsHive hive, string name)
        {
            object sync = base.Sync;

            lock (sync)
            {
                return(this.GetHive(hive).Remove(name));
            }
        }
예제 #3
0
        protected override bool OnTrySet(SettingsHive hive, string name, string value)
        {
            object sync = base.Sync;

            lock (sync)
            {
                this.GetHive(hive)[name] = value;
                return(true);
            }
        }
예제 #4
0
 private Dictionary <string, string> GetHive(SettingsHive hive)
 {
     if (hive != SettingsHive.CurrentUser)
     {
         if (hive != SettingsHive.SystemWide)
         {
             throw new InternalErrorException();
         }
         return(this.systemWideValues);
     }
     return(this.currentUserValues);
 }
예제 #5
0
 private RegistrySettings GetHive(SettingsHive hive)
 {
     if (hive != SettingsHive.CurrentUser)
     {
         if (hive != SettingsHive.SystemWide)
         {
             throw ExceptionUtil.InvalidEnumArgumentException <SettingsHive>(hive, "hive");
         }
         return(RegistrySettings.SystemWide);
     }
     return(RegistrySettings.CurrentUser);
 }
예제 #6
0
        protected override bool OnTrySet(SettingsHive hive, string name, string value)
        {
            RegistrySettings settings = this.GetHive(hive);

            try
            {
                settings.SetString(name, value);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #7
0
        protected override bool OnTryGet(SettingsHive hive, string name, out string value)
        {
            RegistrySettings settings = this.GetHive(hive);

            try
            {
                value = settings.GetString(name);
                return(value > null);
            }
            catch (Exception)
            {
                value = null;
                return(false);
            }
        }
예제 #8
0
        private bool TryGetValue(SettingsHive hive, string path, Type valueType, SettingConverter converter, out object value)
        {
            string str;

            if (!this.TryGet(hive, path, out str))
            {
                value = null;
                return(false);
            }
            try
            {
                value = converter.ConvertFromStorage(valueType, str);
                return(true);
            }
            catch (Exception)
            {
                value = null;
                return(false);
            }
        }
예제 #9
0
        private static void GetHiveQueryOrder(SettingScope scope, out SettingsHive firstTryHive, out SettingsHive?secondTryHive)
        {
            switch (scope)
            {
            case SettingScope.CurrentUser:
                firstTryHive = SettingsHive.CurrentUser;
                break;

            case SettingScope.CurrentUserWithSystemWideOverride:
                firstTryHive = SettingsHive.SystemWide;
                break;

            case SettingScope.SystemWide:
                firstTryHive = SettingsHive.SystemWide;
                break;

            case SettingScope.SystemWideWithCurrentUserOverride:
                firstTryHive = SettingsHive.CurrentUser;
                break;

            default:
                throw ExceptionUtil.InvalidEnumArgumentException <SettingScope>(scope, "scope");
            }
            switch (scope)
            {
            case SettingScope.CurrentUser:
            case SettingScope.SystemWide:
                secondTryHive = 0;
                return;

            case SettingScope.CurrentUserWithSystemWideOverride:
                secondTryHive = 0;
                return;

            case SettingScope.SystemWideWithCurrentUserOverride:
                secondTryHive = 1;
                return;
            }
            throw ExceptionUtil.InvalidEnumArgumentException <SettingScope>(scope, "scope");
        }
예제 #10
0
 public bool TryGet(SettingsHive hive, string path, out string storageValue) =>
 this.OnTryGet(hive, path, out storageValue);
예제 #11
0
 protected abstract bool OnTrySet(SettingsHive hive, string name, string value);
예제 #12
0
 protected abstract bool OnTryGet(SettingsHive hive, string path, out string storageValue);
예제 #13
0
 public bool UnsafeTrySet(SettingsHive hive, string name, string value) =>
 this.OnTrySet(hive, name, value);
예제 #14
0
 protected override bool OnTrySet(SettingsHive hive, string name, string value) =>
 false;
예제 #15
0
 protected override bool OnTryGet(SettingsHive hive, string name, out string value)
 {
     value = null;
     return(false);
 }