Exemplo n.º 1
0
        private static void Save(OptionName.SettingIds name, string variableValue, ProvideSavedSettings settingsProvider)
        {
            var variableName = OptionName.OptionNameForSave(name);

            if (settingsProvider.GetVariableExists(variableName))
            {
                settingsProvider[name] = variableValue;
            }
            else
            {
                settingsProvider[name] = variableValue;
                settingsProvider.SetVariablePersists(variableName, true);
            }
        }
Exemplo n.º 2
0
        private static bool LoadBoolean(OptionName.SettingIds name, ProvideSavedSettings settingsProvider, bool defaultValue)
        {
            var variableName = OptionName.OptionNameForLoad(name);

            if (settingsProvider.GetVariableExists(variableName))
            {
                bool isEnabled;
                var  variableValue = (string)settingsProvider[name];
                bool.TryParse(variableValue, out isEnabled);
                return(isEnabled);
            }

            return(defaultValue);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Load persisted options except the connection options, which are loaded in the ctor
        /// </summary>
        /// <param name="settingsProvider"></param>
        private void LoadPersisted(ProvideSavedSettings settingsProvider)
        {
            var passwordId = OptionName.OptionNameForLoad(OptionName.SettingIds.Password);

            Password = settingsProvider.GetVariableExists(passwordId) ? (string)settingsProvider[OptionName.SettingIds.Password] : defaultPassword;
            var logLevelId = OptionName.OptionNameForLoad(OptionName.SettingIds.LogLevel);

            if (settingsProvider.GetVariableExists(logLevelId))
            {
                string level = (string)settingsProvider[OptionName.SettingIds.LogLevel];
                try
                {
                    LogLevel = (Log.Level)Enum.Parse(typeof(Log.Level), level);
                }
                catch (Exception)
                {
                    LogLevel = defaultLogLevel;
                }
            }
            else
            {
                LogLevel = defaultLogLevel;
            }

            var store = _settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings);

            IsCheckoutEnabled            = LoadBoolean(OptionName.SettingIds.IsCheckoutEnabled, store, defaultCommandsEnabled);
            IsAddEnabled                 = LoadBoolean(OptionName.SettingIds.IsAddEnabled, store, defaultCommandsEnabled);
            IsRevertIfUnchangedEnabled   = LoadBoolean(OptionName.SettingIds.IsRevertIfUnchangedEnabled, store, defaultCommandsEnabled);
            IsRevertEnabled              = LoadBoolean(OptionName.SettingIds.IsRevertEnabled, store, defaultCommandsEnabled);
            PromptBeforeRevert           = LoadBoolean(OptionName.SettingIds.PromptBeforeRevert, store, defaultCommandsEnabled);
            IsGetLatestRevisionEnabled   = LoadBoolean(OptionName.SettingIds.IsGetLatestRevisionEnabled, store, defaultCommandsEnabled);
            IsViewRevisionHistoryEnabled = LoadBoolean(OptionName.SettingIds.IsViewRevisionHistoryEnabled, store, defaultCommandsEnabled);
            IsViewDiffEnabled            = LoadBoolean(OptionName.SettingIds.IsViewDiffEnabled, store, defaultCommandsEnabled);
            IsViewTimeLapseEnabled       = LoadBoolean(OptionName.SettingIds.IsViewTimeLapseEnabled, store, defaultCommandsEnabled);
            AutoCheckoutOnEdit           = LoadBoolean(OptionName.SettingIds.AutoCheckoutOnEdit, store, defaultCommandsEnabled);
            AutoCheckoutOnSave           = LoadBoolean(OptionName.SettingIds.AutoCheckoutOnSave, store, defaultCommandsEnabled);
            AutoAdd    = LoadBoolean(OptionName.SettingIds.AutoAdd, store, defaultCommandsEnabled);
            AutoDelete = LoadBoolean(OptionName.SettingIds.AutoDelete, store, defaultCommandsEnabled);
            IgnoreFilesNotUnderP4Root  = LoadBoolean(OptionName.SettingIds.IgnoreFilesNotUnderP4Root2, store, false);
            OptionName.IsFirstLoadDone = true;

            if (!settingsProvider.GetVariableExists(OptionName.OptionNameForSave(OptionName.SettingIds.Version180OrAfter)))
            {
                // This is the first time we've loaded starting with Release 1.80. So copy the old settings to the new ones.
                Save(settingsProvider);
            }
        }
Exemplo n.º 4
0
 public object this[OptionName.SettingIds name]
 {
     get
     {
         if (_globals != null)
         {
             var variableName = OptionName.OptionNameForLoad(name);
             return(_globals[variableName]);
         }
         return(null);
     }
     set
     {
         if (_globals != null)
         {
             var variableName = OptionName.OptionNameForSave(name);
             _globals[variableName] = value;
         }
     }
 }
Exemplo n.º 5
0
        private void Save(OptionName.SettingIds name, string variableValue)
        {
            if (_globals == null)
            {
                Log.Information(string.Format("globals was null trying to set {0} to {1}", name, variableValue));
                return;
            }

            var variableName = OptionName.OptionNameForSave(name);

            Log.Information(string.Format("globals setting {0} set to {1}", variableName, variableValue));
            if (_globals.VariableExists[variableName])
            {
                _globals[variableName.ToString()] = variableValue;
            }
            else
            {
                _globals[variableName] = variableValue;
                Log.Information(string.Format("globals setting {0} set to persist", variableName));
                _globals.VariablePersists[variableName] = true;
            }
        }