public TypeMap CreateTypeMap(Type source, Type destination, string profileName, MemberList memberList) { TypeMap typeMap = FindExplicitlyDefinedTypeMap(source, destination); if (typeMap == null) { var profileConfiguration = GetProfile(profileName); typeMap = _typeMapFactory.CreateTypeMap(source, destination, profileConfiguration, memberList); typeMap.Profile = profileName; typeMap.IgnorePropertiesStartingWith = _globalIgnore; IncludeBaseMappings(source, destination, typeMap); _typeMaps.Add(typeMap); var typePair = new TypePair(source, destination); _typeMapCache.AddOrUpdate(typePair, typeMap, (tp, tm) => typeMap); OnTypeMapCreated(typeMap); } return(typeMap); }
public TypeMap CreateTypeMap(Type source, Type destination, string profileName, MemberList memberList) { var typePair = new TypePair(source, destination); var typeMap = _userDefinedTypeMaps.GetOrAdd(typePair, tp => { var profileConfiguration = GetProfile(profileName); var tm = _typeMapFactory.CreateTypeMap(source, destination, profileConfiguration, memberList); tm.Profile = profileName; tm.IgnorePropertiesStartingWith = _globalIgnore; IncludeBaseMappings(source, destination, tm); // keep the cache in sync TypeMap _; _typeMapPlanCache.TryRemove(tp, out _); OnTypeMapCreated(tm); return(tm); }); return(typeMap); }