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); }); }
public CallSerializer RegisterCall(string callName, StorageCallback callback) { var call = new CallSerializer(this, callName, callback); _calls[callName] = call; return(call); }
internal CallSerializer(CallStorage owner, string callName, StorageCallback callback) { _callName = callName; _callback = callback; _owner = owner; }
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); } }