diff --git a/API/API/API.csproj b/API/API/API.csproj index 0546254..73c8c00 100644 --- a/API/API/API.csproj +++ b/API/API/API.csproj @@ -98,6 +98,7 @@ + diff --git a/API/API/App_Start/Bootstrapper.cs b/API/API/App_Start/Bootstrapper.cs new file mode 100644 index 0000000..32eb596 --- /dev/null +++ b/API/API/App_Start/Bootstrapper.cs @@ -0,0 +1,31 @@ +using Autofac; +using Autofac.Integration.WebApi; +using System.Reflection; +using System.Web.Http; + +namespace API.App_Start +{ + /// + /// https://autofaccn.readthedocs.io/en/latest/integration/webapi.html#quick-start + /// + public class Bootstrapper + { + public void InitContainer() { + var config = GlobalConfiguration.Configuration; + var builder = new ContainerBuilder(); + builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); + builder.RegisterWebApiFilterProvider(config); + builder.RegisterWebApiModelBinderProvider(); + + RegisterServices(builder); + + var container = builder.Build(); + config.DependencyResolver = new AutofacWebApiDependencyResolver(container); + } + + private void RegisterServices(ContainerBuilder builder) { + // ... builder.RegisterType(); + } + + } +} \ No newline at end of file