public override void ClearMod(Mod Mod) { if (DataPaths.ContainsKey(Mod.ModID)) { DataPaths.Remove(Mod.ModID); } }
public string GetPath(string ModID) { if (DataPaths.ContainsKey(ModID)) { return(DataPaths[ModID]); } else { return(null); } }
private static DataPaths CreatePaths(string newPath) { var path = Path.Combine(Settings.ContainerPath, newPath); Directory.CreateDirectory(path); var paths = new DataPaths { Data = Path.Combine(path, Settings.DATA), NewData = Path.Combine(path, Settings.NEWDATA), }; Directory.CreateDirectory(paths.Data); Directory.CreateDirectory(paths.NewData); return(paths); }
public MainViewModel() { RemoveAlternateDataStreams(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); _manager = ShardManager.GetInstance(); _manager.Shards.CollectionChanged += (sender, args) => { ShardEntries = _manager.Shards; }; ShardEntries = _manager.Shards; string fullPath = Path.Combine(Environment.CurrentDirectory, CONFIG_FILENAME); if (!File.Exists(fullPath)) { return; } using (JsonTextReader jtr = new JsonTextReader(new StreamReader(fullPath))) { JObject config = (JObject)JToken.ReadFrom(jtr); if (config["ClientPaths"] != null) { foreach (JToken token in config["ClientPaths"]) { string path = token.ToObject <string>(); if (File.Exists(path)) { ClientPaths.Add(path); } } } if (config["SelectedClientPath"] != null) { string path = config["SelectedClientPath"].ToObject <string>(); SelectedClientPath = File.Exists(path) ? path : ClientPaths.FirstOrDefault(); } if (config["DataPaths"] != null) { foreach (JToken token in config["DataPaths"]) { string path = token.ToObject <string>(); if (Directory.Exists(path)) { DataPaths.Add(path); } } } if (config["SelectedDataPath"] != null) { string path = config["SelectedDataPath"].ToObject <string>(); SelectedDataPath = Directory.Exists(path) ? path : DataPaths.FirstOrDefault(); } if (config["Shards"] != null) { foreach (JToken token in config["Shards"]) { ShardEntry shard = new ShardEntry { Name = token["Name"]?.ToObject <string>() ?? "Unknown", Address = token["Address"]?.ToObject <string>() ?? "localhost", Port = token["Port"]?.ToObject <int>() ?? 2593, HasStatusProtocol = token["HasStatusProtocol"]?.ToObject <bool>() ?? true, Encryption = token["Encryption"]?.ToObject <bool>() ?? false }; ShardEntries.Add(shard); } } if (config["SelectedShard"] != null) { ShardEntry match = _manager.Shards.FirstOrDefault( s => s.Name == config["SelectedShard"].ToObject <string>()); if (match != null) { SelectedShard = match; } } if (config["Plugins"] != null) { foreach (JToken token in config["Plugins"]) { string pluginPath = token.ToObject <string>(); Plugins.Add(new PluginEntry { Name = Path.GetFileName(pluginPath), FullPath = pluginPath }); } } ReadClassicOptions(config); } }
public override void Clear() { DataPaths.Clear(); }