docs: 补全全部缺失的 XML 文档注释(中文)
- 为全部 5 个项目(Avalonia-API、Avalonia-Common、Avalonia-EFCore、 Avalonia-PC、Avalonia-Services)中缺失注释的类、方法、属性、字段、 接口成员等补全中文 XML 文档注释 - 共修改约 37 个文件,补全约 220+ 处注释 - 修复 ServiceEndpointCollection.cs 中 MapDelete<TService> 语法错误 - 修复 PcAuthService.cs 中 const prefix 位置错乱导致编译失败的问题 - 扫描结果:缺失项 0 - 构建结果:4/4 项目编译通过
This commit is contained in:
@@ -19,6 +19,10 @@ namespace Avalonia_EFCore.Database
|
||||
/// <summary>API refresh token 数据</summary>
|
||||
public DbSet<ApiRefreshTokenEntity> ApiRefreshTokens => Set<ApiRefreshTokenEntity>();
|
||||
|
||||
/// <summary>
|
||||
/// 配置实体映射,包括主键、索引和属性约束。
|
||||
/// </summary>
|
||||
/// <param name="modelBuilder">模型构建器。</param>
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
@@ -2,8 +2,16 @@ using Microsoft.EntityFrameworkCore.Design;
|
||||
|
||||
namespace Avalonia_EFCore.Database
|
||||
{
|
||||
/// <summary>
|
||||
/// 设计时 DbContext 工厂,用于 EF Core 迁移工具生成迁移代码。
|
||||
/// </summary>
|
||||
public class AppDataContextFactory : IDesignTimeDbContextFactory<AppDataContext>
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建用于设计时的 AppDataContext 实例,默认使用 SQLite 提供程序。
|
||||
/// </summary>
|
||||
/// <param name="args">命令行参数。</param>
|
||||
/// <returns>配置好的数据上下文实例。</returns>
|
||||
public AppDataContext CreateDbContext(string[] args)
|
||||
{
|
||||
DatabaseProviderRegistry.RegisterDefaults();
|
||||
|
||||
@@ -12,8 +12,15 @@ namespace Avalonia_EFCore.Database
|
||||
/// </summary>
|
||||
public abstract class AppDbContext(DatabaseConfiguration dbConfig) : DbContext
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据库配置。
|
||||
/// </summary>
|
||||
private readonly DatabaseConfiguration _dbConfig = dbConfig;
|
||||
|
||||
/// <summary>
|
||||
/// 配置数据库提供程序和连接选项。
|
||||
/// </summary>
|
||||
/// <param name="optionsBuilder">选项构建器。</param>
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured) return;
|
||||
@@ -65,12 +72,21 @@ namespace Avalonia_EFCore.Database
|
||||
return base.SaveChanges(acceptAllChangesOnSuccess);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步保存更改,自动设置时间戳。
|
||||
/// </summary>
|
||||
/// <param name="acceptAllChangesOnSuccess">是否在成功时接受所有更改。</param>
|
||||
/// <param name="cancellationToken">取消令牌。</param>
|
||||
/// <returns>受影响的行数。</returns>
|
||||
public override Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = default)
|
||||
{
|
||||
SetTimestamps();
|
||||
return base.SaveChangesAsync(acceptAllChangesOnSuccess, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动设置新增或修改实体的 CreatedAt 和 UpdatedAt 时间戳。
|
||||
/// </summary>
|
||||
private void SetTimestamps()
|
||||
{
|
||||
var entries = ChangeTracker.Entries()
|
||||
|
||||
@@ -17,10 +17,25 @@ namespace Avalonia_EFCore.Database
|
||||
/// </summary>
|
||||
public class DatabaseManager<TContext> where TContext : AppDbContext
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据库上下文实例。
|
||||
/// </summary>
|
||||
private readonly TContext _context;
|
||||
/// <summary>
|
||||
/// 数据库配置。
|
||||
/// </summary>
|
||||
private readonly DatabaseConfiguration _config;
|
||||
/// <summary>
|
||||
/// DI 服务提供程序(可选,用于种子数据中解析服务)。
|
||||
/// </summary>
|
||||
private readonly IServiceProvider? _serviceProvider;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化数据库管理器。
|
||||
/// </summary>
|
||||
/// <param name="context">数据库上下文。</param>
|
||||
/// <param name="config">数据库配置。</param>
|
||||
/// <param name="serviceProvider">可选的 DI 容器。</param>
|
||||
public DatabaseManager(TContext context, DatabaseConfiguration config, IServiceProvider? serviceProvider = null)
|
||||
{
|
||||
_context = context;
|
||||
@@ -128,6 +143,10 @@ namespace Avalonia_EFCore.Database
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前应用程序的版本号,优先读取 AssemblyInformationalVersion,回退到 AssemblyVersion。
|
||||
/// </summary>
|
||||
/// <returns>应用程序版本字符串。</returns>
|
||||
private static string GetApplicationVersion()
|
||||
{
|
||||
var assembly = Assembly.GetEntryAssembly() ?? typeof(TContext).Assembly;
|
||||
@@ -181,10 +200,25 @@ namespace Avalonia_EFCore.Database
|
||||
/// </summary>
|
||||
public class DatabaseVersionInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置数据库提供程序名称。
|
||||
/// </summary>
|
||||
public string Provider { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 获取或设置已应用的迁移列表。
|
||||
/// </summary>
|
||||
public List<string> AppliedMigrations { get; set; } = new();
|
||||
/// <summary>
|
||||
/// 获取或设置待应用的迁移列表。
|
||||
/// </summary>
|
||||
public List<string> PendingMigrations { get; set; } = new();
|
||||
/// <summary>
|
||||
/// 获取或设置是否为最新版本。
|
||||
/// </summary>
|
||||
public bool IsLatest { get; set; }
|
||||
/// <summary>
|
||||
/// 获取或设置数据库是否可连接。
|
||||
/// </summary>
|
||||
public bool CanConnect { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ namespace Avalonia_EFCore.Database
|
||||
/// </summary>
|
||||
public delegate void ProviderConfigurator(DbContextOptionsBuilder optionsBuilder, string connectionString, int timeout);
|
||||
|
||||
/// <summary>
|
||||
/// 保存已注册的数据库提供程序及其配置委托。
|
||||
/// </summary>
|
||||
private static readonly Dictionary<DatabaseProvider, ProviderConfigurator> _providers = new();
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user