Ejemplo n.º 1
0
        /// <summary>
        /// Gets a bool from the ini.
        /// </summary>
        /// <param name="section">Section of the key.</param>
        /// <param name="name">Name of the key.</param>
        /// <param name="mode">Yes/No alternative we should look for.</param>
        /// <param name="defaultValue">Value that should be used when no value is found.</param>
        /// <param name="autoSave">Whether or not the default value should be written if no value is found.</param>
        /// <returns></returns>
        public bool GetBool(string section, string name, BoolSavingMode mode, bool defaultValue = false, bool autoSave = false)
        {
            string sVal = GetString(section, name);

            try{
                int yesIndex = yesAlts.IndexOf(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(sVal));
                int noIndex  = noAlts.IndexOf(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(sVal));
                if (yesIndex != -1 && yesIndex == (int)mode)
                {
                    return(true);
                }
                else if (noIndex != -1 && noIndex == (int)mode)
                {
                    return(false);
                }
                else if (autoSave)
                {
                    SetBool(section, name, defaultValue);
                }
            }catch { SetBool(section, name, defaultValue); }
            return(defaultValue);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Sets a bool in the ini.
 /// </summary>
 /// <param name="section">Section of the key.</param>
 /// <param name="name">Name of the key.</param>
 /// <param name="mode">What common yes/no alternative should we use.</param>
 /// <param name="value">Value that should be written.</param>
 public void SetBool(string section, string name, BoolSavingMode mode, bool value)
 {
     _instance.IniWriteValue(section, name, value ? yesAlts[(int)mode] : noAlts[(int)mode]);
 }