public static void Register(HttpConfiguration config) { config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); config.Formatters.JsonFormatter.UseDataContractJsonSerializer = false; config.Services.Add(typeof(System.Web.Http.ExceptionHandling.IExceptionLogger), new WebApiExceptionLogger()); var container = new WindsorContainer().Install(Configuration.FromAppConfig()).Install(FromAssembly.InDirectory(new AssemblyFilter("bin"))); var httpDependencyResolver = new WindsorHttpDependencyResolver(container); config.DependencyResolver = httpDependencyResolver; // Web API configuration and services // Configure Web API to use only bearer token authentication. config.SuppressDefaultHostAuthentication(); config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType)); // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); }
public void Configuration(IAppBuilder app) { //... var container = new WindsorContainer().Install(new ControllerInstaller()); var httpDependencyResolver = new WindsorHttpDependencyResolver(container); config.DependencyResolver = httpDependencyResolver; //... }
public void Configuration(IAppBuilder app) { HttpConfiguration config = new HttpConfiguration(); var dependencyResolver = new WindsorHttpDependencyResolver(container); config.DependencyResolver = dependencyResolver; // ....... // ....... }
public static WindsorHttpDependencyResolver GetDependencyResolver() { if (_initialized) { return(_resolver); } _initialized = true; Container.Install(FromAssembly.This()); _resolver = new WindsorHttpDependencyResolver(Container); return(_resolver); }
public void Configuration(IAppBuilder app) { var container = new WindsorContainer() .Install( new ControllerInstaller(), new ServiceInstaller()); var httpDependencyResolver = new WindsorHttpDependencyResolver(container); var configuration = new HttpConfiguration(); configuration.MapHttpAttributeRoutes(); configuration.DependencyResolver = httpDependencyResolver; app.UseWebApi(configuration); }
public void Configuration(IAppBuilder appBuilder) { var container = new WindsorContainer().Install( new ControllerInstaller(), new MediatrInstaller(), new DefaultInstaller()); var httpDependencyResolver = new WindsorHttpDependencyResolver(container); HttpConfiguration config = new HttpConfiguration(); config.MapHttpAttributeRoutes(); config.DependencyResolver = httpDependencyResolver; // remove xml as supported media type and just return json config.Formatters.XmlFormatter.SupportedMediaTypes.Remove( config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml")); //var jsonformatter = new JsonMediaTypeFormatter //{ // SerializerSettings = // { // NullValueHandling = NullValueHandling.Ignore // } //}; //config.Formatters.RemoveAt(0); //config.Formatters.Insert(0, jsonformatter); config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); config.Formatters.JsonFormatter.UseDataContractJsonSerializer = false; config .EnableSwagger(c => { c.SingleApiVersion("v1", "Tasks Example API"); c.IncludeXmlComments(GetXmlCommentsPath()); }) .EnableSwaggerUi(c => { c.DocExpansion(DocExpansion.List); }); config.MessageHandlers.Add(new WrappingHandler()); appBuilder.UseWebApi(config); }
private HttpConfiguration ConfigureWebApi() { var config = new HttpConfiguration(); config.Routes.MapHttpRoute( "DefaultApi", "api/{controller}/{id}", new { id = RouteParameter.Optional }); var container = new WindsorContainer().Install(new Installer()); var httpDependencyResolver = new WindsorHttpDependencyResolver(container); config.DependencyResolver = httpDependencyResolver; return(config); }
//private static WindsorContainer _container; public void Configuration(IAppBuilder app) { HttpConfiguration config = new HttpConfiguration(); WebApiConfig.Register(config); app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll); ConfigureOAuthTokenGeneration(app); ConfigureOAuthTokenConsumption(app); var container = new WindsorContainer().Install( new ControllerInstaller(), new DefaultInstaller()); var httpDependencyResolver = new WindsorHttpDependencyResolver(container); config.DependencyResolver = httpDependencyResolver; app.UseWebApi(config); }
public void Configuration(IAppBuilder app) { HttpConfiguration httpConfig = new HttpConfiguration(); WebApiConfig.Register(httpConfig); ConfigureOAuthTokenConsumption(app); ConfigureWebApi(httpConfig); var container = new WindsorContainer(); container.Register(Classes.FromThisAssembly() .Pick().If(t => t.Name.EndsWith("Controller")) .Configure(configurer => configurer.Named(configurer.Implementation.Name)) .LifestylePerWebRequest()); var httpDependencyResolver = new WindsorHttpDependencyResolver(container.Kernel); container.Register(Types.FromAssemblyNamed("CashLady.Services").BasedOn <IConsumer>()); var busControl = Bus.Factory.CreateUsingRabbitMq(cfg => { var host = cfg.Host(new Uri("rabbitmq://localhost/"), h => { h.Username("guest"); h.Password("guest"); }); cfg.ReceiveEndpoint("TestPublisher", ec => { ec.UseMessageScope(); ec.LoadFrom(container); }); }); busControl.Start(); container.Register(Component.For <IBusControl>().Instance(busControl)); container.Register( Component.For <IEventPublisher>().ImplementedBy <MassTransitServiceBus>().Named("EventPublisher") .DependsOn(busControl)); container.Register( Component.For <ICommandSender>() .ImplementedBy <MassTransitServiceBus>().Named("CommandSender") .LifeStyle.Transient); var store = EventStoreFactory.CreateSqlEventStore("EventStoreSQLDatabase"); container.Register(Component.For <IEventStore>().Instance(store)); var eventStore = container.Resolve <IEventStore>(); container.Register( Component.For <IRepository <LoanAggregate> >() .ImplementedBy <Repository <LoanAggregate> >().DependsOn(eventStore) .LifeStyle.Transient); container.Register( Component.For <IRepository <UserAggregate> >() .ImplementedBy <Repository <UserAggregate> >().DependsOn(eventStore) .LifeStyle.Transient); httpConfig.DependencyResolver = httpDependencyResolver; app.UseWebApi(httpConfig); }