|
@@ -0,0 +1,62 @@
|
|
|
+using System;
|
|
|
+using System.IO;
|
|
|
+using System.Text.Json;
|
|
|
+
|
|
|
+namespace fis
|
|
|
+{
|
|
|
+ public class ShellConfig
|
|
|
+ {
|
|
|
+ public readonly static ShellConfig Instance = Load();
|
|
|
+
|
|
|
+ //Gets or sets the app host which is the web App's access url
|
|
|
+ public string AppHost { get; set; } = "app.fis.plus";
|
|
|
+
|
|
|
+ //Gets or sets the App resource path, which stores the web content and its resources.
|
|
|
+ public string AppResourcePath { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App");
|
|
|
+
|
|
|
+ //Gets or sets the api host for local call, usually provider platform apis.
|
|
|
+ public string LocalApiHost { get; set; } = "platform.fis.plus";
|
|
|
+
|
|
|
+ //Gets or sets the resource path for local application resources, eg. icons, images, audios and videos.
|
|
|
+ public string LocalResourcePath { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources");
|
|
|
+
|
|
|
+
|
|
|
+ private static ShellConfig Load()
|
|
|
+ {
|
|
|
+ var configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ShellConfig.json");
|
|
|
+ if (File.Exists(configPath))
|
|
|
+ {
|
|
|
+ ShellConfig? config = null;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ config = JsonSerializer.Deserialize<ShellConfig>(File.ReadAllText(configPath));
|
|
|
+ if(config != null)
|
|
|
+ {
|
|
|
+ return config;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ //
|
|
|
+ }
|
|
|
+ return new ShellConfig()
|
|
|
+ {
|
|
|
+ AppResourcePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App"),
|
|
|
+ LocalResourcePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources"),
|
|
|
+ AppHost = "app.fis.plus",
|
|
|
+ LocalApiHost = "platform.fis.plus"
|
|
|
+ };
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return new ShellConfig()
|
|
|
+ {
|
|
|
+ AppResourcePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App"),
|
|
|
+ LocalResourcePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources"),
|
|
|
+ AppHost = "app.fis.plus",
|
|
|
+ LocalApiHost = "platform.fis.plus"
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|