mirror of
https://github.com/hawkeye-stan/msfs-popout-panel-manager.git
synced 2024-11-24 14:50:10 +00:00
42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
|
using MSFSPopoutPanelManager.Shared;
|
|||
|
using Newtonsoft.Json;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.IO;
|
|||
|
|
|||
|
namespace MSFSPopoutPanelManager.TouchPanelAgent
|
|||
|
{
|
|||
|
internal class ConfigurationReader
|
|||
|
{
|
|||
|
public static List<PlaneProfileInfo> GetPlaneProfilesConfiguration()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
string filePath;
|
|||
|
|
|||
|
if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development")
|
|||
|
filePath = Path.Combine(GetSolutionPath(), $@"ReactClient\public\config\PlanePanelProfile.json");
|
|||
|
else
|
|||
|
filePath = @"ReactClient\config\PlanePanelProfile.json";
|
|||
|
|
|||
|
using (StreamReader reader = new StreamReader(Path.Combine(AppContext.BaseDirectory, filePath)))
|
|||
|
{
|
|||
|
return JsonConvert.DeserializeObject<List<PlaneProfileInfo>>(reader.ReadToEnd());
|
|||
|
}
|
|||
|
}
|
|||
|
catch
|
|||
|
{
|
|||
|
FileLogger.WriteException("PlanePanelProfile.json file is not found or is invalid.", null);
|
|||
|
return new List<PlaneProfileInfo>();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private static string GetSolutionPath()
|
|||
|
{
|
|||
|
var currentDir = Directory.GetCurrentDirectory();
|
|||
|
var path = currentDir.Substring(0, currentDir.IndexOf("WpfApp") - 1);
|
|||
|
|
|||
|
return path;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|