Пример #1
0
 public static Func <string, T, T> BuildWithDefaultValue <T>(ICakeArguments arguments, ICakeEnvironment environment, string prefix)
 {
     ValidateParams(arguments, environment, prefix);
     return((paramName, defaultValue) =>
     {
         var paramValue = GetValue(arguments, environment, prefix, paramName);
         return paramValue != null?TypeConverter.ConvertTo <T>(paramValue) : defaultValue;
     });
 }
Пример #2
0
 public static Func <string, T> BuildRequired <T>(ICakeArguments arguments, ICakeEnvironment environment, string prefix)
 {
     ValidateParams(arguments, environment, prefix);
     return(paramName =>
     {
         var paramValue = GetValue(arguments, environment, prefix, paramName);
         return paramValue != null
             ? TypeConverter.ConvertTo <T>(paramValue)
             : throw new CakeException($"Argument '{paramName}' or environment variable '{GetEnvVarName(prefix, paramName)}' were not set.");
     });
 }