예제 #1
0
 public void Load(StorageCallback callback)
 {
     CallWithStorageDevice(delegate() {
         device.BeginOpenContainer("MisterToken", delegate(IAsyncResult containerResult) {
             StorageContainer container = device.EndOpenContainer(containerResult);
             if (container.FileExists("save.xml")) {
                 Stream input = container.OpenFile("save.xml", FileMode.Open);
                 if (input != null) {
                     try {
                         XmlSerializer serializer = new XmlSerializer(typeof(SaveData));
                         saveData = (SaveData)serializer.Deserialize(input);
                     } catch (Exception) {
                         saveData = new SaveData();
                     } finally {
                         input.Close();
                         callback();
                     }
                 } else {
                     saveData = new SaveData();
                     callback();
                 }
             } else {
                 saveData = new SaveData();
                 callback();
             }
             container.Dispose();
         }, null);
     });
 }
예제 #2
0
 public StorageManager()
 {
     saveData = new SaveData();
     device = null;
 }