Fixed optimize error.

This commit is contained in:
Robin 2016-09-23 22:10:45 +02:00
commit 4ff0f090bb

View file

@ -140,8 +140,13 @@ namespace Greenshot.IniFile {
public Type ValueType {
get {
var valueType = _propertyInfo?.PropertyType ?? _fieldInfo.FieldType;
if (!valueType.IsGenericType)
{
return valueType;
}
var genericTypeDefinition = valueType.GetGenericTypeDefinition();
if (genericTypeDefinition != null && (valueType.IsGenericType && genericTypeDefinition == typeof(Nullable<>))) {
if (genericTypeDefinition != null && genericTypeDefinition == typeof(Nullable<>))
{
// We are dealing with a generic type that is nullable
valueType = Nullable.GetUnderlyingType(valueType);
}
@ -286,8 +291,8 @@ namespace Greenshot.IniFile {
return;
}
} else if (!string.IsNullOrEmpty(propertyValue)) {
var genericTypeDefinition = valueType.GetGenericTypeDefinition();
if (genericTypeDefinition != null && (valueType.IsGenericType && genericTypeDefinition == typeof(Nullable<>))) {
if (valueType.IsGenericType && valueType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
// We are dealing with a generic type that is nullable
valueType = Nullable.GetUnderlyingType(valueType);
}