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); }
private void ClearTypeMap(object sender, TypeMapCreatedEventArgs e) { IObjectMapper existing; _objectMapperCache.TryRemove(new TypePair(e.TypeMap.SourceType, e.TypeMap.DestinationType), out existing); }