using Newtonsoft.Json; using System.Collections.Generic; using System.IO; namespace TGS.Server { /// /// Class for storing server wide settings /// public sealed class ServerConfig { /// /// The filename to save the as /// [JsonIgnore] const string JSONFilename = "ServerConfig.json"; /// /// The most recent version of the config file /// [JsonIgnore] const ulong CurrentVersion = 8; /// /// The version of the /// public ulong Version { get; private set; } = CurrentVersion; /// /// List of paths that contain s /// public List InstancePaths { get; private set; } = new List(); /// /// Port used to access the remotely /// public ushort RemoteAccessPort { get; set; } = 38607; /// /// Path to the directory containing the Python2.7 installation /// public string PythonPath { get; set; } = "C:\\Python27"; /// /// Saves the to a target /// /// The directory in which to save the public void Save(string directory) { var data = JsonConvert.SerializeObject(this, Formatting.Indented); var path = Path.Combine(directory, JSONFilename); File.WriteAllText(path, data); } /// /// Load a from a given /// /// The directory containing the /// The loaded public static ServerConfig Load(string directory) { var configtext = File.ReadAllText(Path.Combine(directory, JSONFilename)); return JsonConvert.DeserializeObject(configtext); } } }