コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }