Esempio n. 1
0
        public bool HasOpenGenericTypeMapDefined(ResolutionContext context)
        {
            var sourceGenericDefinition = context.SourceType.GetGenericTypeDefinition();
            var destGenericDefinition   = context.DestinationType.GetGenericTypeDefinition();

            var genericTypePair = new TypePair(sourceGenericDefinition, destGenericDefinition);

            return(_typeMapExpressionCache.ContainsKey(genericTypePair));
        }
Esempio n. 2
0
        public TypeMap ResolveTypeMap(TypePair typePair)
        {
            var typeMap = _typeMapPlanCache.GetOrAdd(typePair,
                                                     _ =>
                                                     GetRelatedTypePairs(_)
                                                     .Select(
                                                         tp =>
                                                         FindTypeMapFor(tp) ?? (_typeMapPlanCache.ContainsKey(tp) ? _typeMapPlanCache[tp] : null))
                                                     .FirstOrDefault(tm => tm != null));

            return(typeMap);
        }