A setting within an IniFileSection.
Esempio n. 1
0
        /// <summary>
        /// Remove this setting from the section.
        /// </summary>
        public void Remove()
        {
            if (!Section.Settings.Remove(this))
            {
                return;
            }

            IniFileSetting first = Section.SettingsByName[Name];
            var            next  = NextSettingWithSameName;

            NextSettingWithSameName = null;

            if (first == this)
            {
                if (next != null)
                {
                    Section.SettingsByName[Name] = next;
                }
                else
                {
                    Section.SettingsByName.Remove(Name);
                }
            }
            else
            {
                for (; ; first = first.NextSettingWithSameName)
                {
                    if (first.NextSettingWithSameName == this)
                    {
                        first.NextSettingWithSameName = next;
                        break;
                    }
                }
            }
        }
Esempio n. 2
0
        string GetBase(IniFileSetting setting)
        {
            switch (File.Behavior.Duplicates)
            {
            case IniFileDuplicateBehavior.Abort:
            case IniFileDuplicateBehavior.AllowChooseFirst:
            case IniFileDuplicateBehavior.AllowChooseLast:
            case IniFileDuplicateBehavior.IgnoreChooseFirst:
            case IniFileDuplicateBehavior.IgnoreChooseLast:
                return(setting.Value);

            case IniFileDuplicateBehavior.AllowAll:
                if (setting.NextSettingWithSameName != null)
                {
                    throw new Exception("There are multiple settings in this section with the same name. As such, this setting cannot be accessed individually.");
                }
                return(setting.Value);

            default:
                throw new Exception();
            }
        }
Esempio n. 3
0
        string GetBase(IniFileSetting setting)
        {
            switch (File.Behavior.Duplicates) {
                case IniFileDuplicateBehavior.Abort:
                case IniFileDuplicateBehavior.AllowChooseFirst:
                case IniFileDuplicateBehavior.AllowChooseLast:
                case IniFileDuplicateBehavior.IgnoreChooseFirst:
                case IniFileDuplicateBehavior.IgnoreChooseLast:
                    return setting.Value;

                case IniFileDuplicateBehavior.AllowAll:
                    if (setting.NextSettingWithSameName != null)
                        throw new Exception("There are multiple settings in this section with the same name. As such, this setting cannot be accessed individually.");
                    return setting.Value;

                default:
                    throw new Exception();
            }
        }