Dawning.Core
1.0.1
dotnet add package Dawning.Core --version 1.0.1
NuGet\Install-Package Dawning.Core -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Dawning.Core" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dawning.Core" Version="1.0.1" />
<PackageReference Include="Dawning.Core" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Dawning.Core --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Dawning.Core, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Dawning.Core@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Dawning.Core&version=1.0.1
#tool nuget:?package=Dawning.Core&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Dawning.Core
统一 API 响应和异常处理库。
安装
dotnet add package Dawning.Core
功能
- 统一 API 响应 -
ApiResult<T>和PagedResult<T> - 业务异常 - 预定义的异常类型
- 异常处理中间件 - 自动捕获并格式化异常响应
使用
注册中间件
app.UseDawningExceptionHandling();
返回统一响应
[HttpGet]
public ApiResult<UserDto> GetUser(int id)
{
var user = _userService.GetById(id);
return ApiResult<UserDto>.Success(user);
}
// 分页响应
[HttpGet]
public PagedResult<UserDto> GetUsers(int page, int pageSize)
{
var (items, total) = _userService.GetPaged(page, pageSize);
return PagedResult<UserDto>.Success(items, total, page, pageSize);
}
抛出业务异常
throw new NotFoundException("用户不存在");
throw new BusinessException("操作失败");
throw new ValidationException("参数无效");
throw new UnauthorizedException("未授权");
throw new ForbiddenException("禁止访问");
响应格式
{
"success": true,
"code": 200,
"message": "操作成功",
"data": { ... }
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- System.Text.Json (>= 8.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.1 | 162 | 1/2/2026 |