Example #1
0
        //从文件中恢复对象
        public static void LoadFromStorage(string filePath, ITPSerializable target)
        {
            StorageAdapter storageAdapter = ReadFromFile(filePath);

            target.DecodeFirst(storageAdapter[0]);
            target.DecodeSecond(storageAdapter[1]);
        }
Example #2
0
        //保存到文件
        public static void SaveToStorage(string filePath, ITPSerializable target)
        {
            StorageAdapter storageAdapter = new StorageAdapter();

            storageAdapter.Add(target.EncodeFirst());
            storageAdapter.Add(target.EncodeSecond());
            WriteToFile(filePath, storageAdapter.ToJson());
        }