refactor (readonly for static objects in tests and file-scoped namespaces

This commit is contained in:
2024-09-22 17:34:29 +03:00
parent 1625764e0a
commit a80076e2e6
50 changed files with 1196 additions and 1246 deletions

View File

@@ -1,6 +1,5 @@
using BlazorWebAssemblyVisaApiClient.Common.Exceptions;
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider.Exceptions
{
public class UnknownRoleException() : BlazorClientException("Unknown user role");
}
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider.Exceptions;
public class UnknownRoleException() : BlazorClientException("Unknown user role");

View File

@@ -1,15 +1,14 @@
using VisaApiClient;
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider;
public interface IUserDataProvider
{
public interface IUserDataProvider
{
public string? CurrentRole { get; }
public string? CurrentRole { get; }
public Action? OnRoleChanged { get; set; }
public Action? OnRoleChanged { get; set; }
public Task<ApplicantModel> GetApplicant();
public Task<ApplicantModel> GetApplicant();
public void UpdateCurrentRole();
}
}
public void UpdateCurrentRole();
}

View File

@@ -3,23 +3,23 @@ using System.Security.Claims;
using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider.Exceptions;
using VisaApiClient;
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider;
public class UserDataProvider(Client client) : IUserDataProvider
{
public class UserDataProvider(Client client) : IUserDataProvider
private readonly static JwtSecurityTokenHandler tokenHandler = new();
public string? CurrentRole { get; private set; }
public Action? OnRoleChanged { get; set; }
public async Task<ApplicantModel> GetApplicant()
{
private readonly static JwtSecurityTokenHandler tokenHandler = new();
public string? CurrentRole { get; private set; }
public Action? OnRoleChanged { get; set; }
public async Task<ApplicantModel> GetApplicant()
{
return await client.GetApplicantAsync();
}
public void UpdateCurrentRole()
{
public void UpdateCurrentRole()
{
var role = CurrentRole;
if (client.AuthToken is null)
@@ -49,5 +49,4 @@ namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvide
OnRoleChanged?.Invoke();
}
}
}
}
}