Demo/Demo.WebApi/Startup.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using Demo.Data;
using Kernelx.Cmpts.MOI;
using Kernelx.Contexts;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demo.WebApi
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton(new ContextEnvironment());

            //初始化框架运行参数
            services.AddInfrastructures(Configuration, cfg => {
                cfg.Register(nameof(Bus_User), "B-{date:yyMM@args}-{seq:3}", args =>
                {
                    var fiter = $"B-{args["date"]}";
                    return ContextWorkload.Current.GetService<IModelibContext>().Store<Bus_User>()
                    .IsSkipDeleteStatus(false).Where(x => x.Id.StartsWith(fiter)).Max(x => x.Id);
                });
            });

            services.AddCors();
            services.AddResponseCompression(); 
            services.AddControllers();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            var ctxenv = app.ApplicationServices.GetService<ContextEnvironment>();
            ctxenv.RootPath = env.WebRootPath;

            if (env.IsDevelopment())
            {
                ctxenv.IsDevelopment = true;

                app.UseDeveloperExceptionPage();
            }
            else
            {
后面还有 40 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。