// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddMvc().AddXmlSerializerFormatters(); IBookChaptersRepository repos = new SampleBookChaptersRepository(); repos.Init(); services.AddSingleton <IBookChaptersRepository>(repos); // services.AddSwaggerGen(); //services.AddSwaggerGen(); //services.ConfigureSwaggerDocument(options => //{ // options.SingleApiVersion(new Info // { // Version = "v1", // Title = "Book Chapters", // Description = "A sample for Professional C# 6" // }); // options.IgnoreObsoleteActions = true; //}); //services.ConfigureSwaggerSchema(options => //{ // options.DescribeAllEnumsAsStrings = true; // options.IgnoreObsoleteProperties = true; //}); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddMvc().AddXmlSerializerFormatters(); IBookChaptersRepository repos = new SampleBookChaptersRepository(); repos.Init(); services.AddSingleton(repos); services.AddSwaggerGen(); services.ConfigureSwaggerGen(options => { options.SingleApiVersion(new Info { Version = "v1", Title = "Book Chapters", Description = "A sample for Professional C# 6" }); options.IgnoreObsoleteActions(); options.IgnoreObsoleteProperties(); options.DescribeAllEnumsAsStrings(); }); }
// This method gets called by the runtime. Use this method to add services to the container. public async void ConfigureServices(IServiceCollection services) { services.AddMvc().AddXmlSerializerFormatters(); // uncomment the following three lines to use the SampleBookChaptersRepository IBookChaptersRepository repos = new SampleBookChaptersRepository(); services.AddSingleton <IBookChaptersRepository>(repos); await repos.InitAsync(); services.AddEntityFramework() .AddSqlServer() .AddDbContext <BooksContext>(options => options.UseSqlServer(Configuration["Data:BookConnection:ConnectionString"]) ); services.AddSingleton <IBookChaptersRepository, BookChaptersRepository>(); }