1 // Copyright (C) 2014, 2015 Kazuhiro Fujieda <fujieda@users.osdn.me>
\r
3 // Licensed under the Apache License, Version 2.0 (the "License");
\r
4 // you may not use this file except in compliance with the License.
\r
5 // You may obtain a copy of the License at
\r
7 // http://www.apache.org/licenses/LICENSE-2.0
\r
9 // Unless required by applicable law or agreed to in writing, software
\r
10 // distributed under the License is distributed on an "AS IS" BASIS,
\r
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 // See the License for the specific language governing permissions and
\r
13 // limitations under the License.
\r
16 using System.Collections.Generic;
\r
18 using System.Xml.Serialization;
\r
20 namespace KancolleSniffer
\r
22 public interface IHaveState
\r
24 bool NeedSave { get; }
\r
25 void SaveState(Status status);
\r
26 void LoadState(Status status);
\r
31 private readonly string _baseDir = AppDomain.CurrentDomain.BaseDirectory;
\r
32 private readonly string _statusFileName;
\r
33 public static bool Restoring { get; set; }
\r
34 public Achievement Achievement { get; set; }
\r
35 public List<MaterialCount> MaterialHistory { get; set; }
\r
36 public double CondRegenTime { get; set; }
\r
37 public ExMapInfo.ExMapState ExMapState { get; set; }
\r
38 public QuestStatus[] QuestList { get; set; }
\r
39 public QuestCount[] QuestCountList { get; set; }
\r
40 public DateTime QuestLastReset { get; set; }
\r
44 _statusFileName = Path.Combine(_baseDir, "status.xml");
\r
45 CondRegenTime = double.MinValue;
\r
53 var serializer = new XmlSerializer(typeof(Status));
\r
55 using (var file = File.OpenText(_statusFileName))
\r
56 status = (Status)serializer.Deserialize(file);
\r
57 foreach (var property in GetType().GetProperties())
\r
58 property.SetValue(this, property.GetValue(status, null), null);
\r
60 catch (FileNotFoundException)
\r
71 var serializer = new XmlSerializer(typeof(Status));
\r
72 using (var file = File.CreateText(_statusFileName))
\r
73 serializer.Serialize(file, this);
\r