refactor (readonly for static objects in tests and file-scoped namespaces
This commit is contained in:
		| @@ -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"); | ||||
| @@ -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(); | ||||
| } | ||||
| @@ -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(); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user