コード例 #1
0
        /// <summary>
        /// 自动找出实现IAutoMapperConfig接口的配置
        /// </summary>
        /// <param name="assemblies">程序集数组</param>
        public static void AutoRegisterConfig(Assembly[] assemblies)
        {
            var types = ReflectUtil.GetImplClassType(assemblies, typeof(IAutoMapperConfig));

            if (types.IsNullOrLength0())
            {
                return;
            }

            foreach (var t in types)
            {
                var config = t.Assembly.CreateInstance(t.FullName) as IAutoMapperConfig;
                mapperConfigs.Add(config);
            }
        }