Beispiel #1
0
        public void Configuration(IAppBuilder app)
        {
            // Order matters for OWIN pipeline, set OAuth config first.
            ConfigureOAuth(app);

            HttpConfiguration config = new HttpConfiguration();

            WebApiConfig.Register(config);

            app.UseWebApi(config);

            SwaggerConfig.Register(config);
        }
Beispiel #2
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public IServiceProvider ConfigureServices(IServiceCollection services)
 {
     services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
     SwaggerConfig.Register(services);
     return(AutofacConfig.Configure(builder =>
     {
         var types = Assembly.Load("Sqr.DC.Business").GetTypes().Where(c => c.IsSubclassOf(typeof(Autofac.Module)));
         builder.RegisterAssemblyModules(Assembly.GetExecutingAssembly());
         builder.RegisterAssemblyModules(Assembly.Load("Sqr.DC.Business"));
         builder.RegisterAssemblyModules(Assembly.Load("Sqr.DC.EF"));
         builder.Populate(services);
         return null;
     }));
 }
Beispiel #3
0
        public void Configuration(IAppBuilder app)
        {
            HttpConfiguration config = new HttpConfiguration();

            config.MessageHandlers.Add(new ServerCompressionHandler(new GZipCompressor(), new DeflateCompressor()));
            config.MessageHandlers.Add(new LogHandler());
            config.MessageHandlers.Add(new CustomThrottlingHandler());

            WebApiConfig.Register(config);
            Injector.ConfiguracaoSimpleInjector.StartSimpleInjetor(config);
            ConfigureOAuth(app, config);
            SwaggerConfig.Register(config);

            app.UseWebApi(config);
        }
Beispiel #4
0
        public void Bulid()
        {
            string WcsApiServer = Properties.Resources.WcsApiServer;
            var    config       = new HttpSelfHostConfiguration(WcsApiServer);

            config.MapHttpAttributeRoutes();
            //config.Formatters.Add(new PlainTextTypeFormatter());
            config.Routes.MapHttpRoute(name: "DefaultApi",
                                       routeTemplate: "api/{controller}/{action}/{id}",
                                       defaults: new { id = RouteParameter.Optional });
            SwaggerConfig.Register(config);
            using (var sever = new HttpSelfHostServer(config))
            {
                sever.OpenAsync().Wait();
                while (true)
                {
                }
            }
        }
Beispiel #5
0
        public void Configuration(IAppBuilder app)
        {
            app.UseCors(CorsOptions.AllowAll);

            OAuthAuthorizationServerOptions option = new OAuthAuthorizationServerOptions
            {
                TokenEndpointPath         = new PathString("/api/account/login"),
                Provider                  = new ApplicationOAuthProvider(),
                AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(60),
                AllowInsecureHttp         = true
            };

            app.UseOAuthAuthorizationServer(option);
            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());

            var config = new HttpConfiguration();

            WebApiConfig.Register(config);
            app.UseWebApi(config);
#if DEBUG
            SwaggerConfig.Register(config);
#endif
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //var logger = Framework.Logging.Log4Net.LoggerFactory.Create(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            Logger.Info("Application startup - Initializing the Infra Services Configuration");
            try
            {
                //services.Configure<CookiePolicyOptions>(options =>
                //{
                //    // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                //    options.CheckConsentNeeded = context => true;
                //    options.MinimumSameSitePolicy = SameSiteMode.None;
                //});

                var customSettings = this.Configuration.GetSection("CustomSettings").Get <CustomSettings>();
                Logger.Info($"Application startup - Allowed origins: {string.Join(",", customSettings.AllowedOrigins)}");

                services.AddCors();

                services.AddAutofac();


                services.AddSignalR(config =>
                {
                    config.EnableDetailedErrors = true;
                });

                services.AddDbContext <FunzaDBContext>(options => options.UseSqlServer(this.ConnectionString));


                services.AddMvc()
                .SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
                .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver());

                services.AddApiVersioning(o =>
                {
                    o.AssumeDefaultVersionWhenUnspecified = true;
                    o.DefaultApiVersion = new ApiVersion(new DateTime(2016, 7, 1));
                });

                SwaggerConfig.EnableServiceSwaggerMiddleware(services);

                services.AddOptions();


                RefitConfig.Configure(this.Configuration, services, ServiceProvider);

                var autofacServiceProvider = IoCConfig.Init(Configuration, services);

                return(autofacServiceProvider);
            }
            catch (Exception ex)
            {
                Logger.Fatal("Application startup - Execption on Infra Services Configuration", ex);
                throw;
            }
            finally
            {
                Logger.Info("Application startup - Ending the Infra Services Configuration");
                Logger.FlushBuffers();
            }
        }