public static void Register(HttpConfiguration config)
        {
            config.MapHttpAttributeRoutes();
            config.DependencyResolver = new UnityDependencyResolver(UnityConfig.GetConfiguredContainer());

            WebApiUnityActionFilterProvider.RegisterFilterProviders(config);
        }
Ejemplo n.º 2
0
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            //var container = new UnityContainer();
            //container.RegisterType<ITestService, TestService>(new HierarchicalLifetimeManager());
            //container.RegisterType<ITestRepository, TestRepository>(new HierarchicalLifetimeManager());
            //config.DependencyResolver = new UnityResolver(container);
            config.Formatters.RemoveAt(0);
            config.Formatters.Insert(0, new JilFormatter());

            config.DependencyResolver = new UnityDependencyResolver(UnityConfig.GetConfiguredContainer());

            config.Services.Replace(typeof(IExceptionHandler), new CustomExceptionHandler());

            //config.EnableCors();

            WebApiUnityActionFilterProvider.RegisterFilterProviders(config);
            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
        }
Ejemplo n.º 3
0
        public static void Register(HttpConfiguration config)
        {
            config.MapHttpAttributeRoutes();
            config.DependencyResolver = new UnityDependencyResolver(UnityConfig.GetConfiguredContainer());
            config.Services.Add(typeof(IExceptionLogger), new SlabLogExceptionLogger(UnityConfig.GetConfiguredContainer().Resolve <ILogProvider>()));

            WebApiUnityActionFilterProvider.RegisterFilterProviders(config);
        }
Ejemplo n.º 4
0
        public static void Install(HttpConfiguration config, IAppBuilder app)
        {
            WebApiUnityActionFilterProvider.RegisterFilterProviders(config);
            var container = GetContainer();

            var httpClient = container.Resolve <HttpClient>();

            var response = httpClient.GetAsync("http://identity.quinntynebrown.com/api/symetrickeys/get").Result;
            var jObject  = response.Content.ReadAsAsync <JObject>().Result;

            app.UseCors(CorsOptions.AllowAll);

            app.MapSignalR();

            app.Use(typeof(StatusMiddleware));

            config.Filters.Add(new HandleErrorAttribute(container.Resolve <ILoggerFactory>()));



            config.SuppressHostPrincipal();

            var mediator = container.Resolve <IMediator>();

            config.EnableSwagger(c => {
                c.UseFullTypeNameInSchemaIds();
                c.SingleApiVersion("v1", "AspNetNgStarter");
            })
            .EnableSwaggerUi();

            app.UseJwtBearerAuthentication(new JwtOptions("all", "http://identity.quinntynebrown.com", $"{jObject["key"]}"));

            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

            config.Filters.Add(new System.Web.Http.AuthorizeAttribute());

            var jSettings = new JsonSerializerSettings();

            jSettings.Formatting            = Formatting.Indented;
            jSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            jSettings.ContractResolver      = new SignalRContractResolver();
            config.Formatters.JsonFormatter.SerializerSettings = jSettings;


            config.Formatters.Remove(config.Formatters.XmlFormatter);

            GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => JsonSerializer.Create(jSettings));

            config.MapHttpAttributeRoutes();
        }
Ejemplo n.º 5
0
        public static void Register(HttpConfiguration config)
        {
            config.EnableCors(new EnableCorsAttribute("*", "*", "*"));
            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
            WebApiUnityActionFilterProvider.RegisterFilterProviders(config);
            var jsonFormatter = config.Formatters.OfType <JsonMediaTypeFormatter>().First();

            jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
        }
Ejemplo n.º 6
0
        public static void Install(HttpConfiguration config, IAppBuilder app)
        {
            WebApiUnityActionFilterProvider.RegisterFilterProviders(config);
            var container = GetContainer();

            app.UseCors(CorsOptions.AllowAll);

            app.MapSignalR();

            app.Use(typeof(StatusMiddleware));

            config.Filters.Add(new HandleErrorAttribute(container.Resolve <ILoggerFactory>()));

            config.SuppressHostPrincipal();

            var mediator = container.Resolve <IMediator>();

            config.EnableSwagger(c => {
                c.UseFullTypeNameInSchemaIds();
                c.SingleApiVersion("v1", "PhotoBrowser");
            })
            .EnableSwaggerUi();

            var authConfig     = AuthConfiguration.Config;
            var lazyAuthConfig = container.Resolve <Lazy <IAuthConfiguration> >();

            app.UseOAuthAuthorizationServer(new OAuthOptions(lazyAuthConfig, mediator));

            app.UseJwtBearerAuthentication(new JwtOptions(authConfig.JwtAudience, authConfig.JwtIssuer, authConfig.JwtKey));

            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

            config.Filters.Add(new System.Web.Http.AuthorizeAttribute());

            var jSettings = new JsonSerializerSettings();

            jSettings.Formatting            = Formatting.Indented;
            jSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            jSettings.ContractResolver      = new SignalRContractResolver();
            config.Formatters.JsonFormatter.SerializerSettings = jSettings;

            config.Formatters.Remove(config.Formatters.XmlFormatter);

            GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => JsonSerializer.Create(jSettings));

            config.MapHttpAttributeRoutes();
        }
Ejemplo n.º 7
0
        public static void Install(HttpConfiguration config, IAppBuilder app)
        {
            WebApiUnityActionFilterProvider.RegisterFilterProviders(config);

            var container = UnityConfiguration.GetContainer();

            app.MapSignalR();

            config.Filters.Add(new HandleErrorAttribute(UnityConfiguration.GetContainer().Resolve <ILoggerFactory>()));

            app.UseCors(CorsOptions.AllowAll);

            config.SuppressHostPrincipal();

            var mediator = container.Resolve <IMediator>();
            Lazy <IAuthConfiguration> lazyAuthConfiguration = UnityConfiguration.GetContainer().Resolve <Lazy <IAuthConfiguration> >();

            config.EnableSwagger(c => {
                c.UseFullTypeNameInSchemaIds();
                c.SingleApiVersion("v1", "Backlog");
            })
            .EnableSwaggerUi();

            app.UseOAuthAuthorizationServer(new OAuthOptions(lazyAuthConfiguration, mediator));

            app.UseJwtBearerAuthentication(new JwtOptions(lazyAuthConfiguration));

            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

            config.Filters.Add(new AuthorizeAttribute());


            var jSettings = new JsonSerializerSettings();

            jSettings.Formatting            = Formatting.Indented;
            jSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            jSettings.ContractResolver      = new SignalRContractResolver();
            config.Formatters.JsonFormatter.SerializerSettings = jSettings;

            config.Formatters.Remove(config.Formatters.XmlFormatter);

            config.MapHttpAttributeRoutes();
        }
Ejemplo n.º 8
0
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            config.SetCorsPolicyProviderFactory(new CorsPolicyFactory());
            config.EnableCors();

            config.DependencyResolver = new UnityDependencyResolver(UnityConfig.GetConfiguredContainer());


            WebApiUnityActionFilterProvider.RegisterFilterProviders(config);

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
        }
Ejemplo n.º 9
0
        public static void Install(HttpConfiguration config, IAppBuilder app)
        {
            WebApiUnityActionFilterProvider.RegisterFilterProviders(config);

            app.MapSignalR();


            config.Filters.Add(new HandleErrorAttribute(UnityConfiguration.GetContainer().Resolve <ILoggerFactory>()));

            app.UseCors(CorsOptions.AllowAll);

            config.SuppressHostPrincipal();

            IIdentityService          identityService       = UnityConfiguration.GetContainer().Resolve <IIdentityService>();
            Lazy <IAuthConfiguration> lazyAuthConfiguration = UnityConfiguration.GetContainer().Resolve <Lazy <IAuthConfiguration> >();

            config
            .EnableSwagger(c => c.SingleApiVersion("v1", "TournamentBracket"))
            .EnableSwaggerUi();

            app.UseOAuthAuthorizationServer(new OAuthOptions(lazyAuthConfiguration, identityService));

            app.UseJwtBearerAuthentication(new JwtOptions(lazyAuthConfiguration));

            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

            var jSettings = new JsonSerializerSettings();

            jSettings.Formatting            = Formatting.Indented;
            jSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            jSettings.ContractResolver      = new CamelCasePropertyNamesContractResolver();
            config.Formatters.Remove(config.Formatters.XmlFormatter);
            config.Formatters.JsonFormatter.SerializerSettings = jSettings;
            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
        }