add xmldoc comments

This commit is contained in:
Aaron Po
2026-06-18 23:25:50 -04:00
parent 6a66619c70
commit 3034020d56
52 changed files with 1681 additions and 7 deletions

View File

@@ -4,6 +4,11 @@ using Microsoft.Extensions.Configuration;
namespace Infrastructure.Repository.Sql;
/// <summary>
/// Default <see cref="ISqlConnectionFactory"/> implementation that creates SQL Server connections,
/// resolving the connection string from environment variables or application configuration.
/// </summary>
/// <param name="configuration">The application configuration, used as a fallback source for the connection string.</param>
public class DefaultSqlConnectionFactory(IConfiguration configuration)
: ISqlConnectionFactory
{
@@ -11,6 +16,17 @@ public class DefaultSqlConnectionFactory(IConfiguration configuration)
configuration
);
/// <summary>
/// Resolves the SQL Server connection string, preferring (in order): the <c>DB_CONNECTION_STRING</c>
/// environment variable, a connection string built from individual <c>DB_*</c> environment variables
/// via <see cref="SqlConnectionStringHelper.BuildConnectionString"/>, and finally the <c>"Default"</c>
/// connection string from <paramref name="configuration"/>.
/// </summary>
/// <param name="configuration">The application configuration to fall back to.</param>
/// <returns>The resolved SQL Server connection string.</returns>
/// <exception cref="InvalidOperationException">
/// Thrown when no connection string can be resolved from any of the supported sources.
/// </exception>
private static string GetConnectionString(IConfiguration configuration)
{
// Check for full connection string first
@@ -42,6 +58,10 @@ public class DefaultSqlConnectionFactory(IConfiguration configuration)
}
}
/// <summary>
/// Creates a new, unopened <see cref="SqlConnection"/> using the resolved connection string.
/// </summary>
/// <returns>A new <see cref="SqlConnection"/> instance.</returns>
public DbConnection CreateConnection()
{
return new SqlConnection(_connectionString);

View File

@@ -2,7 +2,14 @@ using System.Data.Common;
namespace Infrastructure.Repository.Sql;
/// <summary>
/// Factory for creating database connections used by repositories.
/// </summary>
public interface ISqlConnectionFactory
{
/// <summary>
/// Creates a new, unopened database connection.
/// </summary>
/// <returns>A new <see cref="DbConnection"/> instance.</returns>
DbConnection CreateConnection();
}

View File

@@ -2,6 +2,9 @@ using Microsoft.Data.SqlClient;
namespace Infrastructure.Repository.Sql;
/// <summary>
/// Helper for building SQL Server connection strings from environment variables.
/// </summary>
public static class SqlConnectionStringHelper
{
/// <summary>