private Type GetPropertyType(PropertyDefinition propertyDefinition) { var propertyType = propertyDefinition.IsObjectID ? propertyDefinition.PropertyInfo.PropertyType : propertyDefinition.PropertyType; if (NullableTypeUtility.IsNullableType(propertyType)) { propertyType = NullableTypeUtility.GetBasicType(propertyType); } return(propertyType); }
public void CollectPropertyType(PropertyDefinition propertyDefinition) { ArgumentUtility.CheckNotNull("propertyDefinition", propertyDefinition); var propertyType = propertyDefinition.PropertyType; if (NullableTypeUtility.IsNullableType(propertyType)) { propertyType = NullableTypeUtility.GetBasicType(propertyType); } if (propertyType.IsEnum) { _enumTypes.Add(propertyType); } }
private void CheckEnumValue(object value, PropertyDefinition definition) { if (value != null) { Type underlyingType = definition.IsNullable ? NullableTypeUtility.GetBasicType(definition.PropertyType) : definition.PropertyType; if (!EnumUtility.IsValidEnumValue(underlyingType, value)) { string message = string.Format( "Value '{0}' for property '{1}' is not defined by enum type '{2}'.", value, definition.PropertyName, underlyingType); throw new InvalidEnumValueException(message, definition.PropertyName, underlyingType, value); } } }
public void GetBasicType_ReferenceType() { Assert.That(NullableTypeUtility.GetBasicType(typeof(string)), Is.EqualTo(typeof(string))); }
public void GetBasicType_NullableValueType() { Assert.That(NullableTypeUtility.GetBasicType(typeof(int?)), Is.EqualTo(typeof(int))); }
public void GetBasicType_WithNull_ThrowsArgumentNullException() { Assert.That( () => NullableTypeUtility.GetBasicType(null), Throws.TypeOf <ArgumentNullException>().With.Message.EndsWith("Parameter name: type")); }