예제 #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 CallSerializer RegisterCall(string callName, StorageCallback callback)
        {
            var call = new CallSerializer(this, callName, callback);

            _calls[callName] = call;

            return(call);
        }
예제 #3
0
 internal CallSerializer(CallStorage owner, string callName, StorageCallback callback)
 {
     _callName = callName;
     _callback = callback;
     _owner    = owner;
 }
예제 #4
0
 private void CallWithStorageDevice(StorageCallback callback)
 {
     if (device != null && device.IsConnected) {
         callback();
     } else {
         StorageDevice.BeginShowSelector(delegate(IAsyncResult deviceResult) {
             device = StorageDevice.EndShowSelector(deviceResult);
             if (device != null && device.IsConnected) {
                 callback();
             }
         }, null);
     }
 }