Files
adas-core/adas-core.Domain/Utils/AuthUtils.cs
T
2026-06-27 15:23:26 -07:00

65 lines
1.9 KiB
C#

using adas_core.Domain.Models.Responses;
namespace adas_core.Domain.Utils;
/// <summary>
/// Provides a set of static utility methods for authentication-related operations.
/// </summary>
/// <remarks>
/// This class is sealed and cannot be inherited.
/// </remarks>
public sealed class AuthUtils
{
private LoginResponse _loginResponse = new();
/// <summary>
/// Static constructor that initializes the static <see cref="AuthUtils.InternalInstance"/> field of the <see cref="AuthUtils"/> class by assigning a new <see cref="AuthUtils"/> instance if it has not already been set.
/// </summary>
/// <!-- aidoc:v1 sig=b1904e8 body=05a5e0c -->
static AuthUtils()
{
InternalInstance ??= new AuthUtils();
}
/// <summary>
/// Initializes a new instance of the <see cref="AuthUtils"/> authentication utility class and stores a self-reference in <see cref="AuthUtils.InternalInstance"/>, allowing callers to retrieve the active instance through that property.
/// </summary>
/// <!-- aidoc:v1 sig=cfb2f97 body=ec96561 -->
public AuthUtils()
{
InternalInstance = this;
}
public LoginResponse LoginResponse
{
get
{
lock (_loginResponse)
{
return _loginResponse;
}
}
set
{
lock (_loginResponse)
{
_loginResponse = value;
}
}
}
private static AuthUtils InternalInstance { get; set; }
public static AuthUtils Instance => InternalInstance;
/// <summary>
/// Retrieves the current <see cref="LoginResponse"/> in a thread-safe manner by acquiring a lock on the underlying field.
/// </summary>
/// <returns>The current <see cref="LoginResponse"/> instance.</returns>
public LoginResponse GetLoginResponse()
{
lock (_loginResponse)
{
return _loginResponse;
}
}
}