public Datas() { projectData = new ProjectData(); sortData = new SortData(); settingsData = new SettingsData(); appData = new AppData(); otherData = new OtherData(); }
/// <summary> /// 读取[排序方式] /// </summary> public void Load() { try { //Sort文件的路径(文件夹+文件名+后缀) string _sortFilePath = SortFolderPath + "/Sort - " + AppManager.Systems.ProjectSystem.ProjectData.Id + AppManager.Systems.ProjectSystem.OtherFileSuffix; //FileInfo类 用于读取文件信息 FileInfo _sortFileInfo = new FileInfo(_sortFilePath); /* 判断文件是否存在 */ if (_sortFileInfo.Exists == true) //如果存在 { //读取[Sort]的Json文本中的内容 string _sortJsonText = File.ReadAllText(_sortFilePath); //然后把Json文本解析成SortBaseData对象 SortBaseData _sortBaseData = null; try { _sortBaseData = JsonMapper.ToObject <SortBaseData>(_sortJsonText); } catch (Exception e) { } //把SortBaseData对象,转化为SortData对象 SortData _sortData = SortBaseData.BaseDataToData(_sortBaseData); //然后,赋值 if (_sortData != null) { SortData = _sortData; } } } catch (Exception e) { } }
/// <summary> /// 把[BaseData对象]转换为[Data对象] /// </summary> /// <param name="_baseData">要转换的BaseData对象</param> /// <returns>转换后的Data对象</returns> public static SortData BaseDataToData(SortBaseData _baseData) { if (_baseData != null) { SortData _data = new SortData(); _data.ProgressSortType = (SortType)_baseData.ProgressSortType; _data.PrioritySortType = (SortType)_baseData.PrioritySortType; _data.CreateTimeSortType = (SortType)_baseData.CreateTimeSortType; _data.UpdateTimeSortType = (SortType)_baseData.UpdateTimeSortType; _data.ShowBugNumber = _baseData.ShowBugNumber; return(_data); } else { return(null); } }
/// <summary> /// 清空[项目相关]的数据 /// </summary> public void ClearProjectData() { ProjectData = new ProjectData(); SortData = new SortData(); OtherData = new OtherData(); }