Esempio n. 1
0
        internal static void Register <TSource, TDestination>(IConverter <TSource, TDestination> converter)
        {
            var sourceDestination = new SourceDestination <TSource, TDestination>();

            if (converterDictionary.ContainsKey(sourceDestination))
            {
                return;
            }

            converterDictionary
            .Add(sourceDestination, converter);
        }
Esempio n. 2
0
        internal static IConverter <TSource, TDestination> GetConverter <TSource, TDestination>()
        {
            var sourceDestination = new SourceDestination <TSource, TDestination>();

            if (!converterDictionary.ContainsKey(sourceDestination))
            {
                const string Message =
                    "The convertert for these types was not found. Register it using the Types<TSource, TDestination> method.";

                throw new KeyNotFoundException(Message);
            }

            return
                ((IConverter <TSource, TDestination>)
                 converterDictionary[sourceDestination]);
        }