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 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; }
public EntityFieldExchange( GetFieldValueDelegate classFieldGetter, SetFieldValueDelegate classFieldSetter, GetFieldValueDelegate infoFieldGetter, SetFieldValueDelegate infoFieldSetter, IInfoExchange entityConversion) : base(classFieldGetter, classFieldSetter, infoFieldGetter, infoFieldSetter) { _entityConversion = entityConversion; }
public CollectionFieldExchange( GetFieldValueDelegate classFieldGetter, SetFieldValueDelegate classFieldSetter, GetFieldValueDelegate infoFieldGetter, SetFieldValueDelegate infoFieldSetter, IInfoExchange elementConversion) : base(classFieldGetter, classFieldSetter, infoFieldGetter, infoFieldSetter) { _elementConversion = elementConversion; }
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(); } }