private static void Identity <TSource, TTarget>(TSource source, TTarget target, MapperContext context) { }
private static TTarget ThrowCtor <TSource, TTarget>(TSource source, MapperContext context) => throw new InvalidOperationException($"Don't know how to create {typeof(TTarget).FullName} instances.");
/// <summary> /// Maps a source object to a new target object. /// </summary> /// <typeparam name="TSource">The source type.</typeparam> /// <typeparam name="TTarget">The target type.</typeparam> /// <param name="source">The source object.</param> /// <param name="context">A mapper context.</param> /// <returns>The target object.</returns> public TTarget?Map <TSource, TTarget>(TSource?source, MapperContext context) => Map <TTarget>(source, typeof(TSource), context);
private TTarget?Map <TTarget>(object?source, Type?sourceType, MapperContext context) { if (source == null) { return(default);
/// <summary> /// Maps a source object to a new target object. /// </summary> /// <typeparam name="TTarget">The target type.</typeparam> /// <param name="source">The source object.</param> /// <param name="context">A mapper context.</param> /// <returns>The target object.</returns> public TTarget?Map <TTarget>(object?source, MapperContext context) => Map <TTarget>(source, source?.GetType(), context);