public void AddBindings( DataModelBindingBuilder <TSourceModel, TSourceField, TTargetModel, TTargetField> builder, BindingPair <TSourceField, TTargetField> bindingPair) { if (builder.IsBound(bindingPair.Target)) { return; } var castMethod = GetExplicitCast( bindingPair.Source.FieldType.Type, bindingPair.Source.FieldType.Type, bindingPair.Target.FieldType.Type ); if (castMethod == null) { castMethod = GetExplicitCast( bindingPair.Target.FieldType.Type, bindingPair.Source.FieldType.Type, bindingPair.Target.FieldType.Type ); } if (castMethod == null) { return; } builder.Bind(bindingPair.Target, bindingPair.Source, new TransformFactory(castMethod)); }
public void AddBindings( DataModelBindingBuilder <TSourceModel, TSourceField, TTargetModel, TTargetField> builder, BindingPair <TSourceField, TTargetField> bindingPair) { if (bindingPair.Target.FieldType.Type != typeof(string) || builder.IsBound(bindingPair.Target)) { return; } builder.Bind(bindingPair.Target, bindingPair.Source, ConvertWithToStringTransformFactory.Instance); }
public void AddBindings(DataModelBindingBuilder <TSourceModel, TSourceField, TTargetModel, TTargetField> builder, BindingPair <TSourceField, TTargetField> bindingPair) { if (!IsNumericType(bindingPair.Source.FieldType.Type) || !IsNumericType(bindingPair.Target.FieldType.Type) || builder.IsBound(bindingPair.Target)) { return; } // bind with just a copy operation // since the transform APIs work with objects and box integers etc. // a cast is required in consuming APIs, thus, they handle the cast for us builder.Bind(bindingPair.Target, bindingPair.Source, CopyIdenticalValueTypesRule <TSourceModel, TSourceField, TTargetModel, TTargetField> .ValueCopyTransformFactory.Instance); }
public void AddBindings( DataModelBindingBuilder <TSourceModel, TSourceField, TTargetModel, TTargetField> builder, BindingPair <TSourceField, TTargetField> bindingPair) { if (!MatchingValidTypes(bindingPair.Source.FieldType, bindingPair.Target.FieldType)) { return; } if (builder.IsBound(bindingPair.Target)) { return; } builder.Bind(bindingPair.Target, bindingPair.Source, ValueCopyTransformFactory.Instance); }
public void AddBindings( DataModelBindingBuilder <TSourceModel, TSourceField, TTargetModel, TTargetField> builder, BindingPair <TSourceField, TTargetField> bindingPair) { if (bindingPair.Source.FieldType.Type != typeof(string) || builder.IsBound(bindingPair.Target)) { return; } var tryParseMethod = GetTryParseMethod(bindingPair.Source.FieldType.Type, bindingPair.Target.FieldType.Type); if (tryParseMethod == null) { return; } builder.Bind(bindingPair.Target, bindingPair.Source, new TransformFactory(tryParseMethod)); }