/// <summary>
    /// Configure pipeline
    /// </summary>
    /// <param name="app"></param>
    /// <param name="env"></param>
    /// <param name="mapper"></param>
    public static void Configure(IApplicationBuilder app, IWebHostEnvironment env, AutoMapper.IConfigurationProvider mapper)
    {
        if (env.IsDevelopment())
        {
            mapper.AssertConfigurationIsValid();
            app.UseDeveloperExceptionPage();
        }
        else
        {
            mapper.CompileMappings();
        }

        app.UseDefaultFiles();
        app.UseStaticFiles(new StaticFileOptions
        {
            OnPrepareResponse = ctx =>
            {
                ctx.Context.Response.Headers.Append("Cache-Control", "public,max-age=600");
            }
        });

        app.UseResponseCaching();

        app.UseETagger();

        app.UseIdentityServer();

        app.UseMiddleware(typeof(ErrorHandlingMiddleware));

        app.UseSwagger();
        app.UseSwaggerUI(ConfigureServicesSwagger.SwaggerSettings);

        // Singleton setup for User Identity
        UserIdentity.Instance.Configure(app.ApplicationServices.GetService <IHttpContextAccessor>() !);
    }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, AutoMapper.IConfigurationProvider autoMapper)
        {
            autoMapper.AssertConfigurationIsValid();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Group}/{action=Index}/{id?}");
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        /// </summary>
        /// <param name="app"></param>
        /// <param name="env"></param>
        /// <param name="mapper"></param>
        /// <param name="loggerFactory"></param>
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, AutoMapper.IConfigurationProvider mapper, ILoggerFactory loggerFactory)
        {
            if (env.IsDevelopment())
            {
                mapper.AssertConfigurationIsValid();
            }
            else
            {
                mapper.CompileMappings();
            }

            ConfigureApplication.Configure(app, env, loggerFactory);
        }
Exemplo n.º 4
0
        public void Configure(IApplicationBuilder app, IServiceProvider serviceProvider,
                              AutoMapper.IConfigurationProvider autoMapper, IApiVersionDescriptionProvider apiVersionDescriptionProvider, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseStaticFiles();
            app.UseSpaStaticFiles();

            app.UseMiddleware <GlobalExceptionHandler>();
            app.UseRouting();
            app.UseCors(options => options
                        .SetIsOriginAllowed(x => _ = true)
                        .AllowAnyMethod()
                        .AllowAnyHeader()
                        .AllowCredentials());

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            autoMapper.AssertConfigurationIsValid();
            app.UseSwagger();
            app.UseSwaggerUI(c => {
                // build a swagger endpoint for each discovered API version
                foreach (var description in apiVersionDescriptionProvider.ApiVersionDescriptions
                         .OrderByDescending(x => x.ApiVersion.MajorVersion.GetValueOrDefault()))
                {
                    c.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json",
                                      description.GroupName.ToUpperInvariant());
                }
            });

            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseReactDevelopmentServer(npmScript: "start");
                }
            });
        }
Exemplo n.º 5
0
 /// <summary>
 /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 /// </summary>
 /// <param name="app"></param>
 /// <param name="env"></param>
 /// <param name="mapper"></param>
 public void Configure(IApplicationBuilder app, IWebHostEnvironment env, AutoMapper.IConfigurationProvider mapper)
 {
     ConfigureCommon.Configure(app, env, mapper);
     ConfigureEndpoints.Configure(app);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Configure pipeline
        /// </summary>
        /// <param name="app"></param>
        /// <param name="env"></param>
        /// <param name="mapper"></param>
        public static void Configure(IApplicationBuilder app, IWebHostEnvironment env, AutoMapper.IConfigurationProvider mapper)
        {
            if (env.IsDevelopment())
            {
                mapper.AssertConfigurationIsValid();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                mapper.CompileMappings();
            }

            app.UseDefaultFiles();
            app.UseStaticFiles(new StaticFileOptions
            {
                OnPrepareResponse = ctx =>
                {
                    ctx.Context.Response.Headers.Append("Cache-Control", "public,max-age=600");
                }
            });

            app.UseResponseCaching();

            app.UseETagger();

            app.Map($"{AppData.AuthUrl}", authServer => { authServer.UseIdentityServer(); });

            app.UseMiddleware(typeof(ErrorHandlingMiddleware));

            app.UseSwaggerUI(ConfigureServicesSwagger.SwaggerSettings);

            app.UseSwagger();
        }
Exemplo n.º 7
0
 public DataTableService(MemoryDbContext context,
                         AutoMapper.IConfigurationProvider mappingConfiguration)
 {
     this._context = context;
     this._mappingConfiguration = mappingConfiguration;
 }
Exemplo n.º 8
0
 public static void Configure(IApplicationBuilder app, IWebHostEnvironment env, AutoMapper.IConfigurationProvider mapper)
 {
     if (env.IsDevelopment())
     {
         mapper.AssertConfigurationIsValid();
         app.UseDeveloperExceptionPage();
     }
     else
     {
         mapper.CompileMappings();
     }
 }
Exemplo n.º 9
0
        public static void ConfigureStartup(this IApplicationBuilder app, IWebHostEnvironment env,
                                            AutoMapper.IConfigurationProvider autoMapperConfigProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            // else
            // {
            //     app.UseExceptionHandler("/Error");
            //     // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
            //     app.UseHsts();
            // }

            autoMapperConfigProvider.AssertConfigurationIsValid();
            app.UseHttpsRedirection();
            //app.UseSerilogRequestLogging();
            #region Angular SPA
            //app.UseStaticFiles();
            //if (!env.IsDevelopment())
            //{
            //    app.UseSpaStaticFiles();
            //}
            #endregion
            app.UseRouting();
            //app.UseResponseCaching();
            app.UseResponseCompression();
            // global cors policy
            app.UseCors("_MyAllowedOrigins");
            //app.UseCors(x => x
            //    .SetIsOriginAllowed(origin => true)
            //    .AllowAnyMethod()
            //    .AllowAnyHeader()
            //    .AllowCredentials());
            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                //endpoints.MapControllerRoute(
                //    name: "default",
                //    pattern: "{controller}/{action=Index}/{id?}");
                endpoints.MapControllers()
                .RequireCors("_MyAllowedOrigins");
                endpoints.MapHealthChecks("/health")
                .RequireCors("_MyAllowedOrigins");
            });

            #region Angular SPA
            //app.UseSpa(spa =>
            //{
            //    // To learn more about options for serving an Angular SPA from ASP.NET Core,
            //    // see https://go.microsoft.com/fwlink/?linkid=864501

            //    spa.Options.SourcePath = "ClientApp";

            //    if (env.IsDevelopment())
            //    {
            //        spa.UseAngularCliServer(npmScript: "start");
            //    }
            //});
            #endregion

            #region Swagger
            // Enable middleware to serve generated Swagger as a JSON endpoint.
            app.UseSwagger();

            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
            // specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Fanda API V1");
                //c.RoutePrefix = string.Empty;
            });
            #endregion
        }
 /// <summary>
 /// Converts the given <paramref name="query"/> to type <see cref="IQueryable{TDestination}"/>
 /// and calls <see cref="o:EntityFrameworkQueryableExtensions.SingleOrDefaultAsync"/> on it.
 /// </summary>
 /// <param name="query"></param>
 /// <param name="provider"></param>
 /// <param name="cancellationToken"></param>
 /// <typeparam name="TDestination"></typeparam>
 /// <returns></returns>
 public static async Task <TDestination> ProjectToSingleOrDefaultAsync <TDestination>(this IQueryable query,
                                                                                      IConfigurationProvider provider, CancellationToken cancellationToken = default)
 {
     return(await query
            .ProjectTo <TDestination>(provider)
            .SingleOrDefaultAsync(cancellationToken)
            .ConfigureAwait(false));
 }
Exemplo n.º 11
0
 public WeatherRepository(SandBoxDbContext context, AutoMapper.IConfigurationProvider automapperProvider)
 {
     Context            = context;
     AutomapperProvider = automapperProvider;
 }