예제 #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()));
            }
        }
예제 #2
0
 public DateField(string name, FieldValueDelegate fieldValueDel, SetFieldValueDelegate setFieldValueDel, MinValueDelegate minValueDel, MaxValueDelegate maxValueDel)
 {
     m_name = name;
     m_fieldValueDelegate = fieldValueDel;
     m_setFieldValueDelegate = setFieldValueDel;
     m_minValueDelegate = minValueDel;
     m_maxValueDelegate = maxValueDel;
 }
 public ValueFieldExchange(
     GetFieldValueDelegate classFieldGetter,
     SetFieldValueDelegate classFieldSetter,
     GetFieldValueDelegate infoFieldGetter,
     SetFieldValueDelegate infoFieldSetter,
     IInfoExchange valueConversion)
     : base(classFieldGetter, classFieldSetter, infoFieldGetter, infoFieldSetter)
 {
     _valueConversion = valueConversion;
 }
예제 #4
0
 public ValueFieldExchange(
     GetFieldValueDelegate classFieldGetter,
     SetFieldValueDelegate classFieldSetter,
     GetFieldValueDelegate infoFieldGetter,
     SetFieldValueDelegate infoFieldSetter,
     IInfoExchange valueConversion)
     : base(classFieldGetter, classFieldSetter, infoFieldGetter, infoFieldSetter)
 {
     _valueConversion = valueConversion;
 }
예제 #5
0
 public EntityFieldExchange(
     GetFieldValueDelegate classFieldGetter,
     SetFieldValueDelegate classFieldSetter,
     GetFieldValueDelegate infoFieldGetter,
     SetFieldValueDelegate infoFieldSetter,
     IInfoExchange entityConversion)
     : base(classFieldGetter, classFieldSetter, infoFieldGetter, infoFieldSetter)
 {
     _entityConversion = entityConversion;
 }
예제 #6
0
 public EntityFieldExchange(
     GetFieldValueDelegate classFieldGetter,
     SetFieldValueDelegate classFieldSetter,
     GetFieldValueDelegate infoFieldGetter,
     SetFieldValueDelegate infoFieldSetter,
     IInfoExchange entityConversion)
     : base(classFieldGetter, classFieldSetter, infoFieldGetter, infoFieldSetter)
 {
     _entityConversion = entityConversion;
 }
예제 #7
0
 public CollectionFieldExchange(
     GetFieldValueDelegate classFieldGetter,
     SetFieldValueDelegate classFieldSetter,
     GetFieldValueDelegate infoFieldGetter,
     SetFieldValueDelegate infoFieldSetter,
     IInfoExchange elementConversion)
     : base(classFieldGetter, classFieldSetter, infoFieldGetter, infoFieldSetter)
 {
     _elementConversion = elementConversion;
 }
예제 #8
0
 public FieldExchange(
     GetFieldValueDelegate classFieldGetter,
     SetFieldValueDelegate classFieldSetter,
     GetFieldValueDelegate infoFieldGetter,
     SetFieldValueDelegate infoFieldSetter)
 {
     _classFieldGetter = classFieldGetter;
     _classFieldSetter = classFieldSetter;
     _infoFieldGetter = infoFieldGetter;
     _infoFieldSetter = infoFieldSetter;
 }
예제 #9
0
 public FieldExchange(
     GetFieldValueDelegate classFieldGetter,
     SetFieldValueDelegate classFieldSetter,
     GetFieldValueDelegate infoFieldGetter,
     SetFieldValueDelegate infoFieldSetter)
 {
     _classFieldGetter = classFieldGetter;
     _classFieldSetter = classFieldSetter;
     _infoFieldGetter  = infoFieldGetter;
     _infoFieldSetter  = infoFieldSetter;
 }
        public override void RuntimeInitialize()
        {
            base.RuntimeInitialize();

            if (this.SetValue == null)
            {
                ParameterExpression instanceParameterExpression = Expression.Parameter(typeof(object));
                ParameterExpression valueParameterExpression    = Expression.Parameter(typeof(object));
                UnaryExpression     instanceCastExpression      = Expression.Convert(instanceParameterExpression, this.type);
                UnaryExpression     valueCastExpression         = Expression.Convert(valueParameterExpression, this.location.LocationType);
                string           locationName          = (this.location.FieldInfo == null) ? this.location.PropertyInfo.Name : this.location.FieldInfo.Name;
                Expression       fieldExpr             = PropertyOrFieldCaseSensitive(instanceCastExpression, locationName);
                BinaryExpression assignementExpression = Expression.Assign(fieldExpr, valueCastExpression);
                this.SetValue = Expression.Lambda <SetFieldValueDelegate>(assignementExpression, instanceParameterExpression, valueParameterExpression).Compile();
            }
        }
        public override void RuntimeInitialize()
        {
            base.RuntimeInitialize();

            if (this.SetValue == null)
            {
                ParameterExpression instanceParameterExpression = Expression.Parameter(typeof(object));
                ParameterExpression valueParameterExpression = Expression.Parameter(typeof(object));
                UnaryExpression instanceCastExpression = Expression.Convert(instanceParameterExpression, this.type);
                UnaryExpression valueCastExpression = Expression.Convert(valueParameterExpression, this.location.LocationType);
                string locationName = (this.location.FieldInfo == null) ? this.location.PropertyInfo.Name : this.location.FieldInfo.Name;
                Expression fieldExpr = PropertyOrFieldCaseSensitive(instanceCastExpression, locationName);
                BinaryExpression assignementExpression = Expression.Assign(fieldExpr, valueCastExpression);
                this.SetValue = Expression.Lambda<SetFieldValueDelegate>(assignementExpression, instanceParameterExpression, valueParameterExpression).Compile();
            }
        }