- Skipping parsing nulls of nullable types
This commit is contained in:
Jakub Malek 2016-06-02 11:18:51 +02:00
parent a458e53e25
commit adb02a030f

View File

@ -20,6 +20,10 @@ namespace {{packageName}}.{{packageContext}}.Utils
var isNullable = default(TValue) == null; var isNullable = default(TValue) == null;
string value = RawValue(parameters, name); string value = RawValue(parameters, name);
Preconditions.Evaluate(!string.IsNullOrEmpty(value) || isNullable, string.Format("Required parameter: '{0}' is missing", name)); Preconditions.Evaluate(!string.IsNullOrEmpty(value) || isNullable, string.Format("Required parameter: '{0}' is missing", name));
if (value == null && isNullable)
{
return default(TValue);
}
if (valueType.IsEnum || (valueUnderlyingType != null && valueUnderlyingType.IsEnum)) if (valueType.IsEnum || (valueUnderlyingType != null && valueUnderlyingType.IsEnum))
{ {
return EnumValueOf<TValue>(name, value); return EnumValueOf<TValue>(name, value);