Ejemplo n.º 1
0
        private static IFieldExchange CreateFieldExchange(PropertyInfo domainClassProperty, PropertyInfo infoClassProperty)
        {
            GetFieldValueDelegate domainFieldGetter = CreateGetFieldValueDelegate(domainClassProperty);
            GetFieldValueDelegate infoFieldGetter   = CreateGetFieldValueDelegate(infoClassProperty);
            SetFieldValueDelegate domainFieldSetter = CreateSetFieldValueDelegate(domainClassProperty);
            SetFieldValueDelegate infoFieldSetter   = CreateSetFieldValueDelegate(infoClassProperty);

            Type fieldType = infoClassProperty.PropertyType;

            if (fieldType.IsSubclassOf(typeof(ValueObjectInfo)))
            {
                IInfoExchange conversion = GetDomainObjectConversion(domainClassProperty.PropertyType, infoClassProperty.PropertyType);
                return(new ValueFieldExchange(domainFieldGetter, domainFieldSetter, infoFieldGetter, infoFieldSetter, conversion));
            }
            else if (fieldType.IsSubclassOf(typeof(EntityInfo)))
            {
                IInfoExchange conversion = GetDomainObjectConversion(domainClassProperty.PropertyType, infoClassProperty.PropertyType);
                return(new EntityFieldExchange(domainFieldGetter, domainFieldSetter, infoFieldGetter, infoFieldSetter, conversion));
            }
            else if (CollectionUtils.Contains <Type>(fieldType.GetInterfaces(), delegate(Type t) { return(t.Equals(typeof(IList))); }))
            {
                Type          infoElementType   = GetCollectionElementType(fieldType);
                Type          domainElementType = GetAssociatedDomainClass(infoElementType);
                IInfoExchange conversion        = GetDomainObjectConversion(domainElementType, infoElementType);

                Type typedCollectionFieldExchange = typeof(CollectionFieldExchange <>).MakeGenericType(new Type[] { infoElementType });
                return((IFieldExchange)Activator.CreateInstance(typedCollectionFieldExchange, domainFieldGetter, domainFieldSetter, infoFieldGetter, infoFieldSetter, conversion));
            }
            else
            {
                // assume it is a primitive field
                return(new ValueFieldExchange(domainFieldGetter, domainFieldSetter, infoFieldGetter, infoFieldSetter, new PrimitiveTypeInfoExchange()));
            }
        }
 public ValueFieldExchange(
     GetFieldValueDelegate classFieldGetter,
     SetFieldValueDelegate classFieldSetter,
     GetFieldValueDelegate infoFieldGetter,
     SetFieldValueDelegate infoFieldSetter,
     IInfoExchange valueConversion)
     : base(classFieldGetter, classFieldSetter, infoFieldGetter, infoFieldSetter)
 {
     _valueConversion = valueConversion;
 }
Ejemplo n.º 3
0
 public ValueFieldExchange(
     GetFieldValueDelegate classFieldGetter,
     SetFieldValueDelegate classFieldSetter,
     GetFieldValueDelegate infoFieldGetter,
     SetFieldValueDelegate infoFieldSetter,
     IInfoExchange valueConversion)
     : base(classFieldGetter, classFieldSetter, infoFieldGetter, infoFieldSetter)
 {
     _valueConversion = valueConversion;
 }
Ejemplo n.º 4
0
 public EntityFieldExchange(
     GetFieldValueDelegate classFieldGetter,
     SetFieldValueDelegate classFieldSetter,
     GetFieldValueDelegate infoFieldGetter,
     SetFieldValueDelegate infoFieldSetter,
     IInfoExchange entityConversion)
     : base(classFieldGetter, classFieldSetter, infoFieldGetter, infoFieldSetter)
 {
     _entityConversion = entityConversion;
 }
Ejemplo n.º 5
0
 public EntityFieldExchange(
     GetFieldValueDelegate classFieldGetter,
     SetFieldValueDelegate classFieldSetter,
     GetFieldValueDelegate infoFieldGetter,
     SetFieldValueDelegate infoFieldSetter,
     IInfoExchange entityConversion)
     : base(classFieldGetter, classFieldSetter, infoFieldGetter, infoFieldSetter)
 {
     _entityConversion = entityConversion;
 }
Ejemplo n.º 6
0
 public CollectionFieldExchange(
     GetFieldValueDelegate classFieldGetter,
     SetFieldValueDelegate classFieldSetter,
     GetFieldValueDelegate infoFieldGetter,
     SetFieldValueDelegate infoFieldSetter,
     IInfoExchange elementConversion)
     : base(classFieldGetter, classFieldSetter, infoFieldGetter, infoFieldSetter)
 {
     _elementConversion = elementConversion;
 }
Ejemplo n.º 7
0
 public FieldExchange(
     GetFieldValueDelegate classFieldGetter,
     SetFieldValueDelegate classFieldSetter,
     GetFieldValueDelegate infoFieldGetter,
     SetFieldValueDelegate infoFieldSetter)
 {
     _classFieldGetter = classFieldGetter;
     _classFieldSetter = classFieldSetter;
     _infoFieldGetter = infoFieldGetter;
     _infoFieldSetter = infoFieldSetter;
 }
Ejemplo n.º 8
0
 public FieldExchange(
     GetFieldValueDelegate classFieldGetter,
     SetFieldValueDelegate classFieldSetter,
     GetFieldValueDelegate infoFieldGetter,
     SetFieldValueDelegate infoFieldSetter)
 {
     _classFieldGetter = classFieldGetter;
     _classFieldSetter = classFieldSetter;
     _infoFieldGetter  = infoFieldGetter;
     _infoFieldSetter  = infoFieldSetter;
 }
 public void InitializeForAutoGeneration(GetFieldValueDelegate getFieldValueMethod) => this.GetFieldValueMethod = getFieldValueMethod;