MVC+ICO AutoFac 依赖注入框架

DEMO下载地址: http://download.csdn.net/detail/lhfly/4217929

 

 

文档中包括表结创建的SQL语句

 

 

 public class UserModule : Module
    {
        protected override void Load(ContainerBuilder builder)
        {   

           builder.RegisterType<UserManager>().As<IUserManager>().InstancePerLifetimeScope();

           base.Load(builder);
        }
    }


 

 

 protected void Application_Start()
        {
             
            var builder = new ContainerBuilder();

            //注册Module方法1
            builder.RegisterModule(new UserModule());

            //注册Module方法2  在Web.config中配制
           // builder.RegisterModule(new ConfigurationSettingsReader("autofac"));

            Assembly[] asm = PluginManager.GetAllAssembly().ToArray();
            builder.RegisterAssemblyTypes(asm);

           

            builder.RegisterControllers(Assembly.GetExecutingAssembly());
            builder.RegisterModelBinders(Assembly.GetExecutingAssembly());
            builder.RegisterModelBinderProvider();
            builder.RegisterFilterProvider();//注册Filter           

            builder.RegisterControllers(typeof(MvcApplication).Assembly);
             
            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));



            AreaRegistration.RegisterAllAreas();
            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }


 

 

你可能感兴趣的:(框架,mvc,filter,Module,assembly,application)