Skip to content

Commit

Permalink
Drop optional parameters in ConfigurationExtensions.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey authored and nulltoken committed May 15, 2015
1 parent 631b36c commit 4277559
Showing 1 changed file with 59 additions and 8 deletions.
67 changes: 59 additions & 8 deletions LibGit2Sharp/ConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ public static ConfigurationEntry<T> Get<T>(this Configuration config, string fir
return config.Get<T>(new[] { firstKeyPart, secondKeyPart, thirdKeyPart });
}

/// <summary>
/// Get a configuration value for the given key.
/// </summary>
/// <typeparam name="T">The configuration value type.</typeparam>
/// <param name="config">The configuration being worked with.</param>
/// <param name="key">The key</param>
/// <returns>The configuration value, or the default value for the selected <see typeparamref="T"/>if not found</returns>
public static T GetValueOrDefault<T>(this Configuration config, string key)
{
return ValueOrDefault(config.Get<T>(key), default(T));
}

/// <summary>
/// Get a configuration value for the given key,
/// or <paramref name="defaultValue" /> if the key is not set.
Expand All @@ -76,27 +88,52 @@ public static ConfigurationEntry<T> Get<T>(this Configuration config, string fir
/// <param name="config">The configuration being worked with.</param>
/// <param name="key">The key</param>
/// <param name="defaultValue">The default value if the key is not set.</param>
/// <returns>The configuration value, or the default.</returns>
public static T GetValueOrDefault<T>(this Configuration config, string key, T defaultValue = default(T))
/// <returns>The configuration value, or the default value</returns>
public static T GetValueOrDefault<T>(this Configuration config, string key, T defaultValue)
{
return ValueOrDefault(config.Get<T>(key), defaultValue);
}

/// <summary>
/// Get a configuration value for the given key
/// </summary>
/// <typeparam name="T">The configuration value type.</typeparam>
/// <param name="config">The configuration being worked with.</param>
/// <param name="key">The key.</param>
/// <param name="level">The configuration file into which the key should be searched for.</param>
/// <returns>The configuration value, or the default value for <see typeparamref="T"/> if not found</returns>
public static T GetValueOrDefault<T>(this Configuration config, string key, ConfigurationLevel level)
{
return ValueOrDefault(config.Get<T>(key, level), default(T));
}

/// <summary>
/// Get a configuration value for the given key,
/// or <paramref name="defaultValue" /> if the key is not set.
/// </summary>
/// <typeparam name="T">The configuration value type.</typeparam>
/// <param name="config">The configuration being worked with.</param>
/// <param name="config">The configuration being worked with.</param>
/// <param name="key">The key.</param>
/// <param name="level">The configuration file into which the key should be searched for.</param>
/// <param name="defaultValue">The selector used to generate a default value if the key is not set.</param>
/// <returns>The configuration value, or the default.</returns>
public static T GetValueOrDefault<T>(this Configuration config, string key, ConfigurationLevel level, T defaultValue = default(T))
/// <returns>The configuration value, or the default value.</returns>
public static T GetValueOrDefault<T>(this Configuration config, string key, ConfigurationLevel level, T defaultValue)
{
return ValueOrDefault(config.Get<T>(key, level), defaultValue);
}

/// <summary>
/// Get a configuration value for the given key parts
/// </summary>
/// <typeparam name="T">The configuration value type.</typeparam>
/// <param name="config">The configuration being worked with.</param>
/// <param name="keyParts">The key parts.</param>
/// <returns>The configuration value, or the default value for<see typeparamref="T"/> if not found</returns>
public static T GetValueOrDefault<T>(this Configuration config, string[] keyParts)
{
return ValueOrDefault(config.Get<T>(keyParts), default(T));
}

/// <summary>
/// Get a configuration value for the given key parts,
/// or <paramref name="defaultValue" /> if the key is not set.
Expand All @@ -105,12 +142,26 @@ public static ConfigurationEntry<T> Get<T>(this Configuration config, string fir
/// <param name="config">The configuration being worked with.</param>
/// <param name="keyParts">The key parts.</param>
/// <param name="defaultValue">The default value if the key is not set.</param>
/// <returns>The configuration value, or the default.</returns>
public static T GetValueOrDefault<T>(this Configuration config, string[] keyParts, T defaultValue = default(T))
/// <returns>The configuration value, or the default value.</returns>
public static T GetValueOrDefault<T>(this Configuration config, string[] keyParts, T defaultValue)
{
return ValueOrDefault(config.Get<T>(keyParts), defaultValue);
}

/// <summary>
/// Get a configuration value for the given key parts.
/// </summary>
/// <typeparam name="T">The configuration value type.</typeparam>
/// <param name="config">The configuration being worked with.</param>
/// <param name="firstKeyPart">The first key part.</param>
/// <param name="secondKeyPart">The second key part.</param>
/// <param name="thirdKeyPart">The third key part.</param>
/// <returns>The configuration value, or the default value for the selected <see typeparamref="T"/> if not found</returns>
public static T GetValueOrDefault<T>(this Configuration config, string firstKeyPart, string secondKeyPart, string thirdKeyPart)
{
return ValueOrDefault(config.Get<T>(firstKeyPart, secondKeyPart, thirdKeyPart), default(T));
}

/// <summary>
/// Get a configuration value for the given key parts,
/// or <paramref name="defaultValue" /> if the key is not set.
Expand All @@ -122,7 +173,7 @@ public static ConfigurationEntry<T> Get<T>(this Configuration config, string fir
/// <param name="thirdKeyPart">The third key part.</param>
/// <param name="defaultValue">The default value if the key is not set.</param>
/// <returns>The configuration value, or the default.</returns>
public static T GetValueOrDefault<T>(this Configuration config, string firstKeyPart, string secondKeyPart, string thirdKeyPart, T defaultValue = default(T))
public static T GetValueOrDefault<T>(this Configuration config, string firstKeyPart, string secondKeyPart, string thirdKeyPart, T defaultValue)
{
return ValueOrDefault(config.Get<T>(firstKeyPart, secondKeyPart, thirdKeyPart), defaultValue);
}
Expand Down

0 comments on commit 4277559

Please sign in to comment.