public static CreateContainer ( ) : IContainer | ||
Résultat | IContainer |
/// <summary> /// Register the configuration. /// </summary> /// <param name="config">The configuration.</param> public static void Register(HttpConfiguration config) { config.MapHttpAttributeRoutes(); config.DependencyResolver = new AutofacWebApiDependencyResolver(ContainerFactory.CreateContainer()); config.EnableCors(new EnableCorsAttribute("*", "*", "*")); config.Services.Add(typeof(IExceptionLogger), new ExceptionLogger()); ConfigureFormatters(config); }
/// <summary> /// The configuration entry point for the startup. /// </summary> /// <param name="app">The app builder to configure.</param> public void Configuration(IAppBuilder app) { var contractResolver = CreateContractResolver(); var container = ContainerFactory.CreateContainer(contractResolver); var config = new HttpConfiguration { DependencyResolver = new AutofacWebApiDependencyResolver(container), IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.LocalOnly }; config.MapHttpAttributeRoutes(); config.EnableCors(new EnableCorsAttribute("*", "*", "*")); config.Services.Add(typeof(IExceptionLogger), new ExceptionLogger()); ConfigureFormatters(config, contractResolver); app.UseAutofacMiddleware(container); app.UseAutofacWebApi(config); app.UseWebApi(config); }