public static void Register(HttpConfiguration config) { // Web API configuration and services registration var container = new UnityContainer(); var dataAccessRegistration = new DataAccessRegistration(); var repositoryRegistation = new RepositoryRegistration(); var serviceRegistration = new ServiceRegistration(); dataAccessRegistration.Register(container); repositoryRegistation.Register(container); serviceRegistration.Register(container); config.DependencyResolver = new UnityResolver(container); config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); config.Formatters.JsonFormatter.UseDataContractJsonSerializer = false; // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "AtelieWebApi", Version = "v1" }); }); DataAccessRegistration.Register(services); BusinessRegistration.Register(services); BusinessAggregatorRegistration.Register(services); InfraRegistration.Register(services); AutoMapperRegistration.Register(services); ValidationRegistration.Register(services); }