Skip to content

引用

推荐使用 Visual Studio 2022 开发。

  • 使用vs2022打开项目,通过 Nuget 引用RsCode

    bash
    $ dotnet add package RsCode --version 2.0.2
  • asp.net core项目引用:

    bash
    Install-Package RsCode.AspNetCore -Version 2.0.2

配置

Program.cs中添加配置

csharp
using RsCode;
using RsCode.AspNetCore;

var builder = WebApplication.CreateBuilder(args);
//添加RsCode
builder.Services.AddRsCode();
//自动注册应用接口和实现
string[] assemblies = new string[] { "your.project.Core", "应用程序集名称" }; //todo 替换成实际业务类程序集名称
builder.Services.AutoInject(assemblies); 
//添加数据库,以MySql为例
builder.Services.AddDatabase<MySqlDatabaseProvider>();
builder.Services.AddUnitOfWork();




var app = builder.Build();
if (app.Environment.IsDevelopment())
{
	//启用swaggerui
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAuthorization();

//异常处理
app.UseErrorHandler();

app.MapControllers();
app.Run();

再添加log4net日志配置,即可运行项目

所有文档

查阅所有文档