时间:2021-07-01 10:21:17 帮助过:14人阅读
Global.asax
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } protected void Application_Start() { var builder = new ContainerBuilder(); builder.RegisterModule(new ConfigurationSettingsReader("命名")); Assembly[] asm = PluginHelper.GetAllAssembly().ToArray(); //Assembly.LoadFrom(Path.GetFileNameWithoutExtension("SharpSvn.dll")); builder.RegisterAssemblyTypes(asm); builder.RegisterControllers(Assembly.GetExecutingAssembly()); builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly()); builder.RegisterModelBinderProvider(); builder.RegisterFilterProvider();//注册Filter var container = builder.Build(); DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); }View Code
PluginHelper
View Code配置文件
<configSections> <section name="module" type="Autofac.Configuration.SectionHandler, Autofac.Configuration"/> </configSections> <lq-module> <modules> <module type="命名空间.Service,命名空间"></module> <module type="命名空间.Repository,命名空间"></module> </modules> </lq-module> </configuration> web.config <命名> <files> <file name="Config/Module.config" section="module" /> </files> </命名>View Code
SQL Table 自动生成Net底层-控制器Autofac注入
标签:tab register tostring exe new 系统 技术 and data