public TDestination Map <TSource, TDestination>(TSource source) where TDestination : new() { if (source == null) { throw new ArgumentNullException(nameof(source)); } Func <TSource, TDestination> function = functionCompiler.CompileMappingFunction <TSource, TDestination>(); return(function.Invoke(source)); }
public Func <TSource, TDestination> CompileMappingFunction <TSource, TDestination>() where TDestination : new() { KeyValuePair <Type, Type> key = new KeyValuePair <Type, Type>(typeof(TSource), typeof(TDestination)); if (IsInCash(key)) { return(GetFromCash <TSource, TDestination>(key)); } Func <TSource, TDestination> mappingFunction = functionCompiler.CompileMappingFunction <TSource, TDestination>(); PushToCash(key, mappingFunction); return(mappingFunction); }