core uses branch routing mapwhen integration project model class assignment code generation Middleware


one. usage scenarios

1. Attribute assignment


2. Object initialization

In the above two cases, when there are many attribute fields, the assignment becomes cumbersome. Here, you can use the app. Mapwhen() method to create routing branches and build independent and non-invasive assignment code generation.

2、 Project / demonstration

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)

        // 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())

                //Enable in development environment
                app.UseCodeIntelligencing(typeof(UserEntity).Assembly, typeof(UserDTO).Assembly, typeof(UserModel).Assembly);
                ////Custom routing branch
                //app.UseCodeIntelligencing("/custom_path", options => 
                //    options.Assemblies.Add(typeof(UserEntity).Assembly);
                //    options.Assemblies.Add(typeof(UserDTO).Assembly);
                //    options.Assemblies.Add(typeof(UserModel).Assembly);



            app.UseEndpoints(endpoints =>


3、 Source download




Recommended Today

Parsing c + + STL container list is different from Python list

class template std::list preface 📄Content of this article:C++ STL list 📇 Column:C/C++ | Comprehensive understanding of C + + STL Standard Template Library 👤 Author URI :Bauhinia fish 📆 Creation time:2022-1-3 📟 Little tip: the article is very long and detailed. It is recommended to collect it first 🔙Return to directory (recommended Collection):Comprehensive understanding of […]