net6.0 Ready to test
This commit is contained in:
10
EDA Viewer/Models/Stateless/Methods/IBackgroundPage.cs
Normal file
10
EDA Viewer/Models/Stateless/Methods/IBackgroundPage.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace EDAViewer.Models.Stateless.Methods;
|
||||
|
||||
public interface IBackgroundPage
|
||||
{
|
||||
|
||||
void OnGet(bool? message_clear = null, bool? exceptions_clear = null, bool? set_is_primary_instance = null);
|
||||
|
||||
static string GetRouteName() => nameof(IBackgroundPage).Replace("Page", string.Empty)[1..];
|
||||
|
||||
}
|
10
EDA Viewer/Models/Stateless/Methods/IMethodName.cs
Normal file
10
EDA Viewer/Models/Stateless/Methods/IMethodName.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace EDAViewer.Models.Stateless.Methods;
|
||||
|
||||
public interface IMethodName
|
||||
{
|
||||
|
||||
static string? GetActualAsyncMethodName([CallerMemberName] string? name = null) => name;
|
||||
|
||||
}
|
8
EDA Viewer/Models/Stateless/Methods/IWorkingDirectory.cs
Normal file
8
EDA Viewer/Models/Stateless/Methods/IWorkingDirectory.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace EDAViewer.Models.Stateless.Methods;
|
||||
|
||||
public interface IWorkingDirectory
|
||||
{
|
||||
|
||||
static string GetWorkingDirectory(string? executingAssemblyName, string subDirectoryName) => WorkingDirectory.GetWorkingDirectory(executingAssemblyName, subDirectoryName);
|
||||
|
||||
}
|
50
EDA Viewer/Models/Stateless/Methods/WorkingDirectory.cs
Normal file
50
EDA Viewer/Models/Stateless/Methods/WorkingDirectory.cs
Normal file
@ -0,0 +1,50 @@
|
||||
namespace EDAViewer.Models.Stateless.Methods;
|
||||
|
||||
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