public static IPropertyValue ToModel(this PropertyValueContract propertyValueContract, IMapperSettings mapperSettings, IMutableMessageList <Message>?messages = null) { Type propertyType = mapperSettings.GetTypeByName(propertyValueContract.Type); string propertyName = propertyValueContract.Name; IProperty property = Property.Create(propertyType, propertyName); var propertyValueResult = mapperSettings.DeserializeValue(propertyType, propertyValueContract.Value); object?value = propertyValueResult.GetValueOrDefault(message => { messages?.Add(message); return(null); }); IPropertyValue propertyValue = PropertyValue.Create(property, value: value, valueSource: propertyValueResult.IsSuccess ? ValueSource.Defined : ValueSource.NotDefined); return(propertyValue); }
public static IPropertyContainer ToModel(this PropertyContainerContract contract, IMapperSettings mapperSettings) { var propertyValues = contract.Properties.NotNull().Select(valueContract => valueContract.ToModel(mapperSettings)); return(new PropertyContainer(sourceValues: propertyValues)); }
public static PropertyContainerContract ToContract(this IPropertyContainer propertyContainer, IMapperSettings mapperSettings) { var properties = propertyContainer.Properties.Select(value => value.ToContract(mapperSettings)).ToArray(); return(new PropertyContainerContract() { Properties = properties }); }
public static PropertyValueContract ToContract(this IPropertyValue propertyValue, IMapperSettings mapperSettings) { return(new PropertyValueContract() { Name = propertyValue.PropertyUntyped.Name, Type = mapperSettings.GetTypeName(propertyValue.PropertyUntyped.Type), Value = mapperSettings.SerializeValue(propertyValue.PropertyUntyped.Type, propertyValue.ValueUntyped) }); }
public IBuildMapper ApplySettings(IMapperSettings mapperSettings) { mapperSettings.Config.Invoke(new MapperOptions(mapperInstance.Value.MapperContainer.Value)); return(this); }