zoukankan      html  css  js  c++  java
  • ASP.NET Core妙用分支路由MapWhen集成项目模型类赋值代码生成中间件

    、使用场景

      1.属性赋值

      2.对象初始化

     像以上两种情况,当属性字段较多,赋值就显得繁琐,这里可以使用app.MapWhen()方法创建路由分支构建独立无侵入式赋值代码生成。

    二、项目/演示

      http://101.132.140.8:3613/codeIntelligencing

    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.AddControllers();
            }
    
            // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
            public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
            {
                if (env.IsDevelopment())
                {
                    app.UseDeveloperExceptionPage();
    
                    // 开发环境下启用
                    app.UseCodeIntelligencing(typeof(UserEntity).Assembly, typeof(UserDTO).Assembly, typeof(UserModel).Assembly);
                    //// 自定义路由分支
                    //app.UseCodeIntelligencing("/custom_path", options => 
                    //{
                    //    options.Assemblies.Add(typeof(UserEntity).Assembly);
                    //    options.Assemblies.Add(typeof(UserDTO).Assembly);
                    //    options.Assemblies.Add(typeof(UserModel).Assembly);
                    //});
                }
                app.UseHttpsRedirection();
    
                app.UseRouting();
    
                app.UseAuthorization();
    
                app.UseEndpoints(endpoints =>
                {
                    endpoints.MapControllers();
                });
            }
        }
    

      

     三、源码下载

    CodeIntelligencing

  • 相关阅读:
    SQLServer查看死锁
    css图片叠加和底部定位
    vuejs
    如何优雅的使用vue+vux开发app -03
    ECMAScript 6 入门
    VUX 移动前端框架使用文档
    如何优雅的使用vue+vux开发app -02
    vuejs切换视图同时保持状态
    vuejs与服务器通信
    vuejs件同一个挂载点上切换组
  • 原文地址:https://www.cnblogs.com/GodX/p/14167051.html
Copyright © 2011-2022 走看看