Esempio n. 1
0
        /// <summary>
        /// Creates a <see cref="ITransformer"/> implementation based on the given <paramref name="config"/>.
        /// </summary>
        /// <param name="config">The configuration which contains the type and the optional settings for the <see cref="ITransformer"/> implementation.</param>
        /// <returns></returns>
        public static ITransformer FromTransformerConfig(Transformer config)
        {
            GenericTypeBuilder builder = GenericTypeBuilder.FromType(config.Type);

            var transformer = builder.Build <ITransformer>();

            if (config.Setting == null)
            {
                return(transformer);
            }

            transformer.Configure(config.Setting.ToDictionary(s => s.Key, s => s.Value, StringComparer.OrdinalIgnoreCase));

            return(transformer);
        }