static void ReadData <T>(CDataSave <T> _data, XmlNode _node) where T : CDataSave <T>, new() { bool dataCrypt = _data.DataCrypt(); FieldInfo[] fieldInfo = CDataSave <T> .s_FieldInfos; for (int i = 0; i < fieldInfo.Length; i++) { string readData = _node.SelectSingleNode(fieldInfo[i].Name).InnerText; if (dataCrypt) { readData = TDataCrypt.EasyCryptData(readData, c_DataCryptKey); } fieldInfo[i].SetValue(_data, TDataConvert.Convert(fieldInfo[i].FieldType, readData)); } }
static void SaveData <T>(CDataSave <T> _data, XmlNode _node, string _path) where T : CDataSave <T>, new() { bool dataCrypt = _data.DataCrypt(); FieldInfo[] fieldInfos = CDataSave <T> .s_FieldInfos; foreach (var t in fieldInfos) { var fieldNode = _node.SelectSingleNode(t.Name); string saveData = TDataConvert.Convert(t.FieldType, t.GetValue(_data)); if (dataCrypt) { saveData = TDataCrypt.EasyCryptData(saveData, c_DataCryptKey); } fieldNode.InnerText = saveData; _node.AppendChild(fieldNode); } m_Doc.Save(_path); }