Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public static IPropertyContainer ToModel(this PropertyContainerContract contract, IMapperSettings mapperSettings)
        {
            var propertyValues = contract.Properties.NotNull().Select(valueContract => valueContract.ToModel(mapperSettings));

            return(new PropertyContainer(sourceValues: propertyValues));
        }
Esempio n. 3
0
        public static PropertyContainerContract ToContract(this IPropertyContainer propertyContainer, IMapperSettings mapperSettings)
        {
            var properties = propertyContainer.Properties.Select(value => value.ToContract(mapperSettings)).ToArray();

            return(new PropertyContainerContract()
            {
                Properties = properties
            });
        }
Esempio n. 4
0
 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)
     });
 }
Esempio n. 5
0
 public IBuildMapper ApplySettings(IMapperSettings mapperSettings)
 {
     mapperSettings.Config.Invoke(new MapperOptions(mapperInstance.Value.MapperContainer.Value));
     return(this);
 }