public bool TryGetValue(string key, out ReadWriteProperty <T> value) { try { return(_properties.TryGetValue(key, out value)); } catch (KeyNotFoundException) { throw new KeyNotFoundException($"The read only property {key} was not found."); } }
public ValueListObjectMapper(ReadWriteProperty <T> property) { _property = property; }
public bool TryGetProperty(string propertyName, out ReadWriteProperty <T> property) { return(_properties.TryGetValue(propertyName, out property)); }
public ValueValueDictionaryObjectMapper(ReadWriteProperty <T> property) { _property = property; }
IObjectMapper <TImplementation> GetDictionaryToObjectConverter(ReadWriteProperty <TImplementation> property, Type valueType) { var underlyingType = Nullable.GetUnderlyingType(valueType); if (underlyingType != null) { var converterType = typeof(NullableValueObjectMapper <,>).MakeGenericType(typeof(TImplementation), underlyingType); return((IObjectMapper <TImplementation>)Activator.CreateInstance(converterType, property)); } if (valueType.GetTypeInfo().IsEnum) { return(new EnumObjectMapper <TImplementation>(property)); } if (valueType.IsArray) { var elementType = valueType.GetElementType(); if (ValueObject.IsValueObjectType(elementType)) { var valueConverterType = typeof(ValueArrayObjectMapper <,>).MakeGenericType(typeof(TImplementation), elementType); return((IObjectMapper <TImplementation>)Activator.CreateInstance(valueConverterType, property)); } var elementConverter = _cache.GetConverter(elementType); var converterType = typeof(ObjectArrayObjectMapper <,>).MakeGenericType(typeof(TImplementation), elementType); return((IObjectMapper <TImplementation>)Activator.CreateInstance(converterType, property, elementConverter)); } if (ValueObject.IsValueObjectType(valueType)) { return(new ValueObjectMapper <TImplementation>(property)); } if (valueType.ClosesType(typeof(IEnumerable <>))) { if (valueType.ClosesType(typeof(IDictionary <,>))) { Type[] genericArguments = valueType.GetClosingArguments(typeof(IDictionary <,>)).ToArray(); var keyType = genericArguments[0]; var elementType = genericArguments[1]; if (ValueObject.IsValueObjectType(keyType)) { if (ValueObject.IsValueObjectType(elementType)) { var valueConverterType = typeof(ValueValueDictionaryObjectMapper <, ,>).MakeGenericType(typeof(TImplementation), keyType, elementType); return((IObjectMapper <TImplementation>)Activator.CreateInstance(valueConverterType, property)); } else { var elementConverter = _cache.GetConverter(elementType); var valueConverterType = typeof(ValueObjectDictionaryObjectMapper <, ,>).MakeGenericType(typeof(TImplementation), keyType, elementType); return((IObjectMapper <TImplementation>)Activator.CreateInstance(valueConverterType, property, elementConverter)); } } throw new InvalidOperationException("A dictionary with a reference type key is not supported: " + property.Property.Name); } if (valueType.ClosesType(typeof(IList <>)) || valueType.ClosesType(typeof(IEnumerable <>))) { Type[] genericArguments = valueType.GetClosingArguments(typeof(IEnumerable <>)).ToArray(); var elementType = genericArguments[0]; if (ValueObject.IsValueObjectType(elementType)) { var valueConverterType = typeof(ValueListObjectMapper <,>).MakeGenericType(typeof(TImplementation), elementType); return((IObjectMapper <TImplementation>)Activator.CreateInstance(valueConverterType, property)); } var elementConverter = _cache.GetConverter(elementType); var converterType = typeof(ObjectListObjectMapper <,>).MakeGenericType(typeof(TImplementation), elementType); return((IObjectMapper <TImplementation>)Activator.CreateInstance(converterType, property, elementConverter)); } } return(new ObjectObjectMapper <TImplementation>(property, _cache.GetConverter(valueType))); }
public EnumObjectMapper(ReadWriteProperty <T> property) { _property = property; }
public NullableValueObjectMapper(ReadWriteProperty <T> property) { _property = property; }
public ObjectListObjectMapper(ReadWriteProperty <T> property, IObjectConverter converter) { _property = property; _converter = converter; }
public ValueObjectDictionaryObjectMapper(ReadWriteProperty <T> property, IObjectConverter valueConverter) { _property = property; _valueConverter = valueConverter; }
public ValueObjectMapper(ReadWriteProperty <T> property) { _property = property; _typeConverter = TypeDescriptor.GetConverter(property.Property.PropertyType); }
public ObjectObjectMapper(ReadWriteProperty <T> property, IObjectConverter converter) { _property = property; _converter = converter; _typeConverter = TypeDescriptor.GetConverter(property.Property.PropertyType); }