Initial Commit
This commit is contained in:
9
Shared/Models/IWorkingDirectory.cs
Normal file
9
Shared/Models/IWorkingDirectory.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Barcode.Host.Shared.Models;
|
||||
|
||||
public interface IWorkingDirectory
|
||||
{
|
||||
|
||||
static string GetWorkingDirectory(string? executingAssemblyName, string subDirectoryName) =>
|
||||
WorkingDirectory.GetWorkingDirectory(executingAssemblyName, subDirectoryName);
|
||||
|
||||
}
|
15
Shared/Models/Stateless/IAppSettingsController.cs
Normal file
15
Shared/Models/Stateless/IAppSettingsController.cs
Normal file
@ -0,0 +1,15 @@
|
||||
namespace Barcode.Host.Shared.Models.Stateless;
|
||||
|
||||
public interface IAppSettingsController<T>
|
||||
{
|
||||
|
||||
enum Action : int
|
||||
{
|
||||
App = 0,
|
||||
DevOps = 1
|
||||
}
|
||||
|
||||
static string GetRouteName() => nameof(IAppSettingsController<T>)[1..^10];
|
||||
T GetAppSettings();
|
||||
|
||||
}
|
10
Shared/Models/Stateless/IAppSettingsRepository.cs
Normal file
10
Shared/Models/Stateless/IAppSettingsRepository.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace Barcode.Host.Shared.Models.Stateless;
|
||||
|
||||
public interface IAppSettingsRepository<T>
|
||||
{
|
||||
|
||||
T GetAppSettings();
|
||||
string GetBuildNumberAndGitCommitSeven();
|
||||
void VerifyConnectionStrings();
|
||||
|
||||
}
|
10
Shared/Models/Stateless/IMethodName.cs
Normal file
10
Shared/Models/Stateless/IMethodName.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Barcode.Host.Shared.Models.Stateless;
|
||||
|
||||
public interface IMethodName
|
||||
{
|
||||
|
||||
static string? GetActualAsyncMethodName([CallerMemberName] string? name = null) => name;
|
||||
|
||||
}
|
50
Shared/Models/WorkingDirectory.cs
Normal file
50
Shared/Models/WorkingDirectory.cs
Normal file
@ -0,0 +1,50 @@
|
||||
namespace Barcode.Host.Shared.Models;
|
||||
|
||||
internal abstract class WorkingDirectory
|
||||
{
|
||||
|
||||
internal static string GetWorkingDirectory(string? executingAssemblyName, string subDirectoryName)
|
||||
{
|
||||
string result = string.Empty;
|
||||
if (executingAssemblyName is null)
|
||||
throw new Exception();
|
||||
string traceFile;
|
||||
List<string> directories = new();
|
||||
Environment.SpecialFolder[] specialFolders = new Environment.SpecialFolder[]
|
||||
{
|
||||
Environment.SpecialFolder.LocalApplicationData,
|
||||
Environment.SpecialFolder.ApplicationData,
|
||||
Environment.SpecialFolder.History,
|
||||
Environment.SpecialFolder.CommonApplicationData,
|
||||
Environment.SpecialFolder.InternetCache
|
||||
};
|
||||
foreach (Environment.SpecialFolder specialFolder in specialFolders)
|
||||
directories.Add(Path.Combine(Environment.GetFolderPath(specialFolder), subDirectoryName, executingAssemblyName));
|
||||
foreach (string directory in directories)
|
||||
{
|
||||
for (int i = 1; i < 3; i++)
|
||||
{
|
||||
if (i == 1)
|
||||
result = directory;
|
||||
else
|
||||
result = string.Concat("D", directory[1..]);
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(result))
|
||||
_ = Directory.CreateDirectory(result);
|
||||
traceFile = string.Concat(result, @"\", DateTime.Now.Ticks, ".txt");
|
||||
File.WriteAllText(traceFile, traceFile);
|
||||
File.Delete(traceFile);
|
||||
break;
|
||||
}
|
||||
catch (Exception) { result = string.Empty; }
|
||||
}
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
break;
|
||||
}
|
||||
if (string.IsNullOrEmpty(result))
|
||||
throw new Exception("Unable to set working directory!");
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user