private T GetValue <T>(string key, T defaultValue) where T : struct
        {
            object val;

            return(this.TryGetValue(key, out val)
                                ? ObjectConverter.ToPrimitive <T>(val, defaultValue) : defaultValue);
        }
Example #2
0
 /// <summary>
 /// Get option or default value.
 /// </summary>
 /// <param name="optionName">The option name.</param>
 /// <param name="defaultValue">The default value.</param>
 /// <returns>The option or default value.</returns>
 /// <seealso cref="GetOption(string)"/>
 public virtual T GetOption <T>(string optionName, T defaultValue) where T : struct
 {
     return(ObjectConverter.ToPrimitive <T>(this.GetOption(optionName), defaultValue));
 }