Alexandria.IniFileSetting.IniFileSetting C# (CSharp) Метод

IniFileSetting() публичный Метод

Initialise the setting.
public IniFileSetting ( IniFileSection section, string name, string value ) : System
section IniFileSection
name string
value string
Результат System
        public IniFileSetting(IniFileSection section, string name, string value)
        {
            if (section == null)
                throw new ArgumentNullException("section");
            if (name == null)
                throw new ArgumentNullException("name");
            if (value == null)
                throw new ArgumentNullException("value");
            Section = section;
            Name = name;
            Value = value;

            IniFileSetting first;

            // Insert this into section.SettingsByName using the duplicate behavior setting.
            if (!section.SettingsByName.TryGetValue(name, out first))
                section.SettingsByName[name] = this;
            else {
                switch (File.Behavior.Duplicates) {
                    case IniFileDuplicateBehavior.AllowAll:
                    case IniFileDuplicateBehavior.AllowChooseFirst:
                        for (var last = first; ; last = last.NextSettingWithSameName)
                            if (last.NextSettingWithSameName == null) {
                                last.NextSettingWithSameName = this;
                                break;
                            }
                        break;

                    case IniFileDuplicateBehavior.Abort:
                        throw new InvalidOperationException("This IniFile may not have duplicate keys within a section.");

                    case IniFileDuplicateBehavior.AllowChooseLast:
                        NextSettingWithSameName = first;
                        section.SettingsByName[name] = this;
                        break;

                    case IniFileDuplicateBehavior.IgnoreChooseFirst:
                        return;

                    case IniFileDuplicateBehavior.IgnoreChooseLast:
                        first.Remove();
                        section.SettingsByName[name] = this;
                        break;

                    default:
                        throw new Exception();
                }
            }

            Section.Settings.Add(this);
        }