public object ResolveValue(ResolutionContext context, IMappingEngineRunner mappingEngine)
        {
            var ctorArgs = new List <object>();

            foreach (var map in CtorParams)
            {
                var result = map.ResolveValue(context);

                var sourceType      = result.Type;
                var destinationType = map.Parameter.ParameterType;

                var typeMap = mappingEngine.ConfigurationProvider.ResolveTypeMap(result, destinationType);

                Type targetSourceType = typeMap != null ? typeMap.SourceType : sourceType;

                var newContext = context.CreateTypeContext(typeMap, result.Value, null, targetSourceType,
                                                           destinationType);

                if (typeMap == null && map.Parameter.IsOptional)
                {
                    object value = map.Parameter.DefaultValue;
                    ctorArgs.Add(value);
                }
                else
                {
                    var value = mappingEngine.Map(newContext);
                    ctorArgs.Add(value);
                }
            }

            return(_runtimeCtor.Value(ctorArgs.ToArray()));
        }
示例#2
0
 public virtual void SetValue(object destination, object value)
 {
     _lateBoundPropertySet.Value(destination, value);
 }
示例#3
0
 public override object GetValue(object source)
 {
     return(_lateBoundFieldGet.Value(source));
 }
示例#4
0
 public void SetValue(object destination, object value)
 {
     _lateBoundFieldSet.Value(destination, value);
 }
 public override object GetValue(object source)
 {
     return(_lateBoundPropertyGet.Value(source));
 }
 public override object GetValue(object source)
 {
     return(_memberType == null
         ? null
         : _lateBoundMethod.Value(source, new object[0]));
 }