/// <summary> /// Get a mapper. /// </summary> /// <typeparam name="TEntity">Type of entity to get a mapper for.</typeparam> /// <exception cref="MappingNotFoundException">Did not find a mapper for the specified entity.</exception> /// <returns></returns> public static IEntityMapper <TEntity> GetEntityMapper <TEntity>() { EnsureThatAssembliesHaveBeenScanned(); var mapper1 = _provider.GetBase <TEntity>(); var mapper = mapper1 as IEntityMapper <TEntity>; if (mapper != null) { return(mapper); } if (!UseAutoMappers) { throw new MappingException(typeof(TEntity), "Expected to find a mapper for " + typeof(TEntity).FullName); } IEntityMapper em; if (_mirrorMappers.TryGetValue(typeof(TEntity), out em) && em is IEntityMapper <TEntity> ) { return((EntityMapper <TEntity>)em); } em = new MirrorMapper <TEntity>(); _mirrorMappers[typeof(TEntity)] = em; return((IEntityMapper <TEntity>)em); }
/// <summary> /// Get a mapper. /// </summary> /// <typeparam name="TEntity">Type of entity to get a mapper for.</typeparam> /// <exception cref="MappingNotFoundException">Did not find a mapper for the specified entity.</exception> /// <returns></returns> public static IEntityMapper <TEntity> GetBaseMapper <TEntity>() { EnsureThatAssembliesHaveBeenScanned(); var mapper = (IEntityMapper <TEntity>)_provider.GetBase <TEntity>(); return(mapper); }