Exemple #1
0
        /// <summary>
        /// 通过所有约定的注册器,注册指定的程序集的类型,查看方法<see cref="IocManager.AddConventionalRegistrar"/>
        /// </summary>
        /// <param name="assembly">将要注册的程序集</param>
        /// <param name="config">额外的配置项</param>
        public void RegisterAssemblyByConvention(Assembly assembly, ConventionalRegistrationConfig config)
        {
            var context = new ConventionalRegistrationContext(this, config, assembly);

            foreach (var registrar in _conventionalRegistrars)
            {
                registrar.RegisterAssembly(context);
            }

            if (config.InstallInstallers)
            {
                IocContainer.Install(FromAssembly.Instance(assembly));
            }
        }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="iocManager"></param>
 /// <param name="config"></param>
 /// <param name="assembly"></param>
 public ConventionalRegistrationContext(IIocManager iocManager, ConventionalRegistrationConfig config, Assembly assembly)
 {
     IocManager = iocManager;
     Config     = config;
     Assembly   = assembly;
 }