一、使用場景
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
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/238282.html
標籤:.NET Core
上一篇:.net npoi控制元件,列寬行高自適應的時候,速度特別慢,如何優化
下一篇:求影像邊緣提取示例代碼
