Esempio n. 1
0
        protected override void Load(Autofac.ContainerBuilder builder)
        {
            try
            {
                //注册无效的类型
                RegisterInvalidTypes();

                Assembly[] assemblies = SystemHelper.LoadAppAssemblies();
                builder.RegisterAssemblyTypesWithLiftTimeScope(assemblies).AsImplementedInterfaces().AsSelf();

                //注册WCF的契约
                //builder.RegisterWCFContract(assemblies, m => m.Location.EndsWith(".Service.Interface.dll", StringComparison.CurrentCultureIgnoreCase));

                //注册ModelBinders
                builder.RegisterModelBinders(typeof(Int32ListModelBinder).Assembly);
                builder.RegisterModelBinderProvider();
                //注册Controllers
                builder.RegisterControllers(assemblies, m => m.Location.EndsWith(".Web.dll", StringComparison.CurrentCultureIgnoreCase));
                //注册路由
                builder.RegisterInstance(RouteTable.Routes).As <RouteCollection>();
                //注册GlobalFilters
                builder.RegisterInstance(GlobalFilters.Filters).As <GlobalFilterCollection>();
                //注册ModelBinders
                builder.RegisterInstance(ModelBinders.Binders);
                #region
                ////注册缓存
                //builder.RegisterType<DefaultCacheProvider>().Named<ICacheProvider>("aspnet").AsSelf().SingleInstance();
                //builder.RegisterType<AppFabricCacheProvider>().Named<ICacheProvider>("appfabric").AsSelf().SingleInstance();

                ////注册日志
                //builder.RegisterLogger();
                #endregion
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 2
0
 public ServiceRegistration()
     : this(() => SystemHelper.LoadAppAssemblies())
 {
 }