phdesign.NppToolBucket.Infrastructure.Settings.GetBool C# (CSharp) Method

GetBool() public method

public GetBool ( SettingsSection section, string keyName, bool defaultValue ) : bool
section SettingsSection
keyName string
defaultValue bool
return bool
        public bool GetBool(SettingsSection section, string keyName, bool defaultValue)
        {
            var setting = GetSetting(section.ToString(), keyName);
            if (setting == null || string.IsNullOrEmpty(setting.Value))
                return defaultValue;
            if (setting.Value.Equals("true", StringComparison.CurrentCultureIgnoreCase) || setting.Value == "1")
                return true;
            if (setting.Value.Equals("false", StringComparison.CurrentCultureIgnoreCase) || setting.Value == "0")
                return false;

            return defaultValue;
        }

Usage Example

Example #1
0
        internal static void CommandMenuInit()
        {
            _settings = new Settings(IniFilePath);
            _showTabBarIcons = _settings.GetBool(SettingsSection.Global, "ShowTabBarIcons", true);
            FindAndReplace.MatchCase = _settings.GetBool(SettingsSection.FindAndReplace, "MatchCase", false);
            FindAndReplace.MatchWholeWord = _settings.GetBool(SettingsSection.FindAndReplace, "MatchWholeWord", false);
            FindAndReplace.SearchBackwards = _settings.GetBool(SettingsSection.FindAndReplace, "SearchBackwards", false);
            FindAndReplace.SearchFromBegining = _settings.GetBool(SettingsSection.FindAndReplace, "SearchFromBegining", false);
            FindAndReplace.UseRegularExpression = _settings.GetBool(SettingsSection.FindAndReplace, "UseRegularExpression", false);
            var findHistory = _settings.Get(SettingsSection.FindAndReplace, "FindHistory", null);
            if (!string.IsNullOrEmpty(findHistory))
                FindAndReplace.FindHistory = new List<string>(Deserialise(findHistory));
            var replaceHistory = _settings.Get(SettingsSection.FindAndReplace, "ReplaceHistory", null);
            if (!string.IsNullOrEmpty(replaceHistory))
                FindAndReplace.ReplaceHistory = new List<string>(Deserialise(replaceHistory));

            SetCommand((int)CmdIndex.IndentationSettings, "Change indentation settings", IndentationSettings.Show);
            SetCommand((int)CmdIndex.FindAndReplace, "Multiline find and replace", FindAndReplace.Show, new ShortcutKey(false, true, true, Keys.F));
            SetCommand((int)CmdIndex.Seperator1, "---", null);
            SetCommand((int)CmdIndex.GenerateGuid, "Generate GUID", Helpers.GenerateGuid);
            SetCommand((int)CmdIndex.GenerateLoremIpsum, "Generate Lorem Ipsum", Helpers.GenerateLoremIpsum);
            SetCommand((int)CmdIndex.ComputeMD5Hash, "Compute MD5 hash", Helpers.ComputeMD5Hash);
            SetCommand((int)CmdIndex.ComputeSHA1Hash, "Compute SHA1 hash", Helpers.ComputeSHA1Hash);
            SetCommand((int)CmdIndex.Base64Encode, "Base 64 encode", Helpers.Base64Encode);
            SetCommand((int)CmdIndex.Base64Decode, "Base 64 decode", Helpers.Base64Decode);
            SetCommand((int)CmdIndex.Seperator2, "---", null);
            SetCommand((int)CmdIndex.OpenConfigFile, "Open config file", OpenConfigFile);
            SetCommand((int)CmdIndex.About, "About", About);
        }
All Usage Examples Of phdesign.NppToolBucket.Infrastructure.Settings::GetBool