public static void Load(string servername, string username, string charactername) { string rootpath; if (string.IsNullOrWhiteSpace(Settings.GlobalSettings.ProfilesPath)) { rootpath = Path.Combine(CUOEnviroment.ExecutablePath, "Data", "Profiles"); } else { rootpath = Settings.GlobalSettings.ProfilesPath; } string path = FileSystemHelper.CreateFolderIfNotExists(rootpath, username, servername, charactername); string fileToLoad = Path.Combine(path, "profile.json"); ProfilePath = path; CurrentProfile = ConfigurationResolver.Load <Profile>(fileToLoad) ?? new Profile(); CurrentProfile.Username = username; CurrentProfile.ServerName = servername; CurrentProfile.CharacterName = charactername; ValidateFields(CurrentProfile); }
public static void Load(string servername, string username, string charactername) { string path = FileSystemHelper.CreateFolderIfNotExists(CUOEnviroment.ExecutablePath, "Data", "Profiles", username, servername, charactername); string fileToLoad = Path.Combine(path, "profile.json"); if (!File.Exists(fileToLoad)) { Current = new Profile(username, servername, charactername); } else { Current = ConfigurationResolver.Load <Profile>(fileToLoad, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All, MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead }); if (Current == null) { Current = new Profile(username, servername, charactername); } else { Current.Username = username; Current.ServerName = servername; Current.CharacterName = charactername; } } }
public static void Load(string servername, string username, string charactername) { string path = FileSystemHelper.CreateFolderIfNotExists(CUOEnviroment.ExecutablePath, "Data", "Profiles", username, servername, charactername); string fileToLoad = Path.Combine(path, "profile.json"); if (!File.Exists(fileToLoad)) { Current = new Profile(username, servername, charactername); } else { Current = ConfigurationResolver.Load <Profile>(fileToLoad); if (Current == null) { Current = new Profile(username, servername, charactername); } else { Current.Username = username; Current.ServerName = servername; Current.CharacterName = charactername; } } ValidateFields(Current); ProfileLoaded?.Invoke(); }
public static void Load(string language) { string path = FileSystemHelper.CreateFolderIfNotExists(CUOEnviroment.ExecutablePath, "Language"); string fileToLoad = Path.Combine(path, language); if (!File.Exists(fileToLoad)) { Current = new Language(); } else { Current = ConfigurationResolver.Load <Language>(fileToLoad, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All, MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead }); if (Current == null) { Current = new Language(); } } }
public void Load(string servername, string username, string charactername) { string path = FileSystemHelper.CreateFolderIfNotExists(Engine.ExePath, "Data", "Profiles", username, servername, charactername); // FIXME: this is a temporary patch to change the profile settings name safety string fileToLoad = Path.Combine(path, "settings.json"); string newPath = Path.Combine(path, "profile.json"); if (File.Exists(newPath)) { if (File.Exists(fileToLoad)) { try { File.Delete(fileToLoad); } catch (Exception) { Log.Message(LogTypes.Warning, $"Failed to delete file: '{fileToLoad}'"); } } fileToLoad = newPath; } // if (!File.Exists(fileToLoad)) { Current = new Profile(username, servername, charactername); } else { Current = ConfigurationResolver.Load <Profile>(fileToLoad, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All, MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead }); if (Current == null) { Current = new Profile(username, servername, charactername); } else { Current.Username = username; Current.ServerName = servername; Current.CharacterName = charactername; } } }
public void Load(string servername, string username, string charactername) { string path = FileSystemHelper.CreateFolderIfNotExists(Engine.ExePath, "Data", "Profiles", username, servername, charactername); if (!File.Exists(Path.Combine(path, "settings.json"))) { Current = new Profile(username, servername, charactername); } else { Current = ConfigurationResolver.Load <Profile>(Path.Combine(path, "settings.json")) ?? new Profile(username, servername, charactername); } }
public static void Load(string name) { string ext = Path.GetExtension(name); if (string.IsNullOrEmpty(ext)) { name = name + ".json"; } if (File.Exists(name)) { Current = ConfigurationResolver.Load <Profile>(name); } }
public void Load(string servername, string username, string charactername) { string path = FileSystemHelper.CreateFolderIfNotExists(Engine.ExePath, "Data", "Profiles", username, servername, charactername); if (!File.Exists(Path.Combine(path, Engine.SettingsFile))) { Current = new Profile(username, servername, charactername); } else { Current = ConfigurationResolver.Load <Profile>(Path.Combine(path, Engine.SettingsFile), new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All, MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead }) ?? new Profile(username, servername, charactername); } }