private static GetOptionalParamInt ( string paramName, int defaultValue, IProviderConfiguration config ) : int | ||
paramName | string | |
defaultValue | int | |
config | IProviderConfiguration | |
Résultat | int |
private static int GetOptionalParamInt(string paramName, int defaultValue, IProviderConfiguration config)
{
string paramValuePreParsed;
var paramValue = defaultValue;
if (!config.Properties.TryGetValue(paramName, out paramValuePreParsed)) return paramValue;
if (!int.TryParse(paramValuePreParsed, out paramValue))
throw new ArgumentException(String.Format("{0} invalid. Must be int", paramName));
return paramValue;
}