本文整理汇总了C#中ResolutionContext.CreateTypeContext方法的典型用法代码示例。如果您正苦于以下问题:C# ResolutionContext.CreateTypeContext方法的具体用法?C# ResolutionContext.CreateTypeContext怎么用?C# ResolutionContext.CreateTypeContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResolutionContext
的用法示例。
在下文中一共展示了ResolutionContext.CreateTypeContext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveValue
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: Map
public object Map(ResolutionContext context)
{
var typeMap = context.MapperContext.ConfigurationProvider.FindClosedGenericTypeMapFor(context);
var newContext = context.CreateTypeContext(typeMap, context.SourceValue, context.DestinationValue,
context.SourceType, context.DestinationType);
return context.MapperContext.Runner.Map(newContext);
}
示例3: Map
public object Map(ResolutionContext context)
{
var source = context.SourceValue;
var sourceType = source.GetType();
var sourceTypeDetails = new TypeDetails(sourceType, _ => true, _ => true);
var membersDictionary = sourceTypeDetails.PublicReadAccessors.ToDictionary(p => p.Name, p => p.GetMemberValue(source));
var newContext = context.CreateTypeContext(null, membersDictionary, context.DestinationValue, membersDictionary.GetType(), context.DestinationType);
return context.Engine.Map(newContext);
}
示例4: Map
public object Map(ResolutionContext context, IMappingEngineRunner mapper)
{
var newSource = context.TypeMap.Substitution(context.SourceValue);
var typeMap = mapper.ConfigurationProvider.ResolveTypeMap(newSource.GetType(), context.DestinationType);
var substitutionContext = context.CreateTypeContext(typeMap, newSource, context.DestinationValue,
newSource.GetType(), context.DestinationType);
return mapper.Map(substitutionContext);
}
示例5: Map
public object Map(ResolutionContext context, IMappingEngineRunner mapper)
{
var contextTypePair = new TypePair(context.SourceType, context.DestinationType);
Func<TypePair, IObjectMapper> missFunc = tp => context.Engine.ConfigurationProvider.GetMappers().FirstOrDefault(m => m.IsMatch(context));
var typeMap = mapper.ConfigurationProvider.CreateTypeMap(context.SourceType, context.DestinationType, _profileName);
context = context.CreateTypeContext(typeMap, context.SourceValue, context.DestinationValue, context.SourceType, context.DestinationType);
var map = (context.Engine as MappingEngine)._objectMapperCache.GetOrAdd(contextTypePair, missFunc);
return map.Map(context, mapper);
}