/// <summary> /// Sets <paramref name="value"/> to <paramref name="key"/> of <paramref name="section"/> or inserts new <paramref name="value"/> if <paramref name="section"/> /// with <paramref name="key"/> already exists into accosiated ini file /// </summary> /// <param name="section">Section</param> /// <param name="key">Key</param> /// <param name="value">Value</param> /// <returns>Current <see cref="INI"/> for next usage e.g. <code> /// <para><see cref="INI"/> obj = <see cref="new"/> <see cref="INI"/>("settings.ini");</para> /// <para>obj.<see cref="SetValue"/></para> /// <para>.<see cref="SetValue"/></para> /// <para>...</para> /// </code></returns> public INI SetValue(string section, string key, object value) { if (disposed) { throw new ObjectDisposedException(nameof(INI)); } modified = true; var i = GetEntry(section, key); if (i == null) { i = new INIEntry(section, key, value.ToString()); entries.Add(i); } else { int p = entries.IndexOf(i); entries[p].Value = value; } if (INIMode == INIMode.UpdateOnAction) { Apply(); } return(this); }
/// <summary> /// Sets <see cref="INIEntry"/> or inserts new value if <see cref="INIEntry.Section"/> with <see cref="INIEntry.Key"/> /// already exists into accosiated ini file /// </summary> /// <param name="entry">Single INI entry</param> /// <returns>Current<see cref="INI"/> for next usage e.g. <code> /// <para><see cref="INI"/> obj = <see cref="new"/> <see cref="INI"/>("settings.ini");</para> /// <para>obj.<see cref="SetValue(INIEntry)"/></para> /// <para>.<see cref="SetValue(INIEntry)"/></para> /// <para>...</para> /// </code></returns> public INI SetValue(INIEntry entry) { if (disposed) { throw new ObjectDisposedException(nameof(INI)); } modified = true; var i = GetEntry(entry.Section, entry.Key); if (i == null) { entries.Add(entry); } else { int p = entries.IndexOf(i); entries[p] = entry; } if (INIMode == INIMode.UpdateOnAction) { Apply(); } return(this); }