|
| 1 | +using Microsoft.AspNetCore.Hosting; |
| 2 | +using Microsoft.Extensions.DependencyInjection; |
| 3 | +using Microsoft.Extensions.Logging; |
| 4 | +using JsonApiDotNetCoreExample.Data; |
| 5 | +using Microsoft.EntityFrameworkCore; |
| 6 | +using JsonApiDotNetCore.Extensions; |
| 7 | +using System.Reflection; |
| 8 | + |
| 9 | +namespace JsonApiDotNetCoreExample |
| 10 | +{ |
| 11 | + /// <summary> |
| 12 | + /// This should be in JsonApiDotNetCoreExampleTests project but changes in .net core 3.0 |
| 13 | + /// do no longer allow that. See https://github.com/aspnet/AspNetCore/issues/15373. |
| 14 | + /// </summary> |
| 15 | + public class NoDefaultPageSizeStartup : Startup |
| 16 | + { |
| 17 | + public NoDefaultPageSizeStartup(IWebHostEnvironment env) |
| 18 | + : base(env) |
| 19 | + { } |
| 20 | + |
| 21 | + public override void ConfigureServices(IServiceCollection services) |
| 22 | + { |
| 23 | + var loggerFactory = new LoggerFactory(); |
| 24 | + var mvcBuilder = services.AddMvcCore(); |
| 25 | + services |
| 26 | + .AddSingleton<ILoggerFactory>(loggerFactory) |
| 27 | + .AddLogging(builder => |
| 28 | + { |
| 29 | + builder.AddConsole(); |
| 30 | + }) |
| 31 | + .AddDbContext<AppDbContext>(options => options.UseNpgsql(GetDbConnectionString()), ServiceLifetime.Transient) |
| 32 | + .AddJsonApi(options => { |
| 33 | + options.Namespace = "api/v1"; |
| 34 | + options.IncludeTotalRecordCount = true; |
| 35 | + options.EnableResourceHooks = true; |
| 36 | + options.LoaDatabaseValues = true; |
| 37 | + options.AllowClientGeneratedIds = true; |
| 38 | + }, |
| 39 | + discovery => discovery.AddAssembly(Assembly.Load(nameof(JsonApiDotNetCoreExample))), |
| 40 | + mvcBuilder: mvcBuilder); |
| 41 | + } |
| 42 | + } |
| 43 | +} |
0 commit comments