/// <summary> /// Registers <paramref name="configItem"/> against one or more command names. /// </summary> /// <param name="configItem">The config item to register.</param> /// <param name="commands">One or more command names to register this config item against.</param> public void Add(GitConfigItem configItem, params string[] commands) { foreach (var command in commands) { _configByCommand.AddOrUpdate( command, addValueFactory: _ => new[] { configItem }, updateValueFactory: (_, items) => items.Append(configItem)); } }
/// <summary> /// Add <paramref name="configItem"/> to this builder. /// </summary> /// <remarks> /// Any prior config item with the same key will be replaced. /// </remarks> /// <param name="configItem">The config item to add to the builder.</param> public void Add(GitConfigItem configItem) { // Append or replace config item based upon its key var index = _configItems.IndexOf(item => string.Equals(item.Key, configItem.Key, StringComparison.OrdinalIgnoreCase)); if (index == -1) { _configItems.Add(configItem); } else { _configItems[index] = configItem; } }