public void SaveFacGenData() { try { string path = System.IO.Path.Combine("CharacterReload", "CharacterReload.json"); PlatformFilePath filePath = new PlatformFilePath(EngineFilePaths.ConfigsPath, path); string json = JsonConvert.SerializeObject(this._facGenRecordData, Newtonsoft.Json.Formatting.Indented); Common.PlatformFileHelper.SaveFileString(filePath, json); // StreamWriter streamWriter = new StreamWriter(path, false); // streamWriter.Write(json); // streamWriter.Flush();// 清空缓存 // streamWriter.Close(); } catch (JsonException e) { InformationManager.DisplayMessage(new InformationMessage("CharacterReload save FacGenRecordData failed" + e.Message)); } }
public void LoadFacGenData() { string path = System.IO.Path.Combine("CharacterReload", "CharacterReload.json"); PlatformFilePath filePath = new PlatformFilePath(EngineFilePaths.ConfigsPath, path); if (platformFileHelper.FileExists(filePath)) { try { string json = Common.PlatformFileHelper.GetFileContentString(filePath); if (json != null) { this._facGenRecordData = (List <FacGenRecordData>)JsonConvert.DeserializeObject(json, typeof(List <FacGenRecordData>)); } } catch (JsonException e) { InformationManager.DisplayMessage(new InformationMessage("CharacterReload load FacGenRecordData failed" + e.Message)); } } }
public object LoadDataFromConfig(String key, Type type) { string path = System.IO.Path.Combine(_configRootPath, key + ".json"); PlatformFilePath filePath = new PlatformFilePath(EngineFilePaths.ConfigsPath, path); if (platformFileHelper.FileExists(filePath)) { try { string json = Common.PlatformFileHelper.GetFileContentString(filePath); if (json != null) { return(JsonConvert.DeserializeObject(json, type)); } } catch (JsonException e) { InformationManager.DisplayMessage(new InformationMessage("CharacterReload load FacGenRecordData failed" + e.Message)); return(null); } } return(null); }