From c28f3dbf1d7f1bd3c6c61296495ec31db16e22d7 Mon Sep 17 00:00:00 2001
From: AnalogFeelings <51166756+AnalogFeelings@users.noreply.github.com>
Date: Wed, 14 Aug 2024 19:43:47 +0200
Subject: [PATCH] [App -> Services] Move _CREDENTIAL_FILENAME to AppConstants.
---
Source/Bluechirp.Library/Constants/AppConstants.cs | 5 +++++
Source/Bluechirp/Services/Security/CredentialService.cs | 7 ++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/Source/Bluechirp.Library/Constants/AppConstants.cs b/Source/Bluechirp.Library/Constants/AppConstants.cs
index 357a1d7..23c752b 100644
--- a/Source/Bluechirp.Library/Constants/AppConstants.cs
+++ b/Source/Bluechirp.Library/Constants/AppConstants.cs
@@ -50,4 +50,9 @@ public static class AppConstants
/// The folder name used for the app's log folder.
///
public const string LOG_FOLDER = "Logs";
+
+ ///
+ /// The filename used for the credentials storage file.
+ ///
+ public const string CREDENTIAL_FILENAME = "profiles.ebjson";
}
diff --git a/Source/Bluechirp/Services/Security/CredentialService.cs b/Source/Bluechirp/Services/Security/CredentialService.cs
index 735feb2..2dd6172 100644
--- a/Source/Bluechirp/Services/Security/CredentialService.cs
+++ b/Source/Bluechirp/Services/Security/CredentialService.cs
@@ -16,10 +16,12 @@
// along with this program. If not, see .
#endregion
+using Bluechirp.Library.Constants;
using Bluechirp.Library.Models;
using Bluechirp.Library.Services.Security;
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
@@ -40,14 +42,13 @@ internal class CredentialService : ICredentialService
private Dictionary _profileCredentials;
- private const string _CREDENTIAL_FILENAME = "profiles.ebjson";
-
public CredentialService(IEncryptionService encryptionService)
{
_encryptionService = encryptionService;
}
///
+ [MemberNotNull(nameof(_profileCredentials))]
public async Task LoadProfileDataAsync()
{
StorageFile profilesFile = await GetProfilesFileAsync();
@@ -116,7 +117,7 @@ public async Task RemoveProfileDataAsync(ProfileCredentials credentials)
private async Task GetProfilesFileAsync()
{
StorageFolder folder = ApplicationData.Current.LocalFolder;
- StorageFile profilesFile = await folder.CreateFileAsync(_CREDENTIAL_FILENAME, CreationCollisionOption.OpenIfExists);
+ StorageFile profilesFile = await folder.CreateFileAsync(AppConstants.CREDENTIAL_FILENAME, CreationCollisionOption.OpenIfExists);
return profilesFile;
}