public async Task <GameSaveErrorStatus> DeleteContainer() { if (m_saveProvider == null) { throw new InvalidOperationException("The save system is not initialized."); } GameSaveOperationResult result = await m_saveProvider.DeleteContainerAsync(c_saveContainerName); return(result.Status); }
public static async void Save(string data, string filename) { const string c_saveContainerDisplayName = "GameSave"; const string c_saveBlobName = "data"; string c_saveContainerName = filename; var gameSaveProvider = await GetGameSaveProvider(); if (gameSaveProvider == null) { return; } //Now you have a GameSaveProvider (formerly ConnectedStorageSpace) //Next you need to call CreateContainer to get a GameSaveContainer (formerly ConnectedStorageContainer) GameSaveContainer gameSaveContainer = gameSaveProvider.CreateContainer(c_saveContainerName); // this will create a new named game save container with the name = to the input name //Parameter //string name // To store a value in the container, it needs to be written into a buffer, then stored with // a blob name in a Dictionary. DataWriter writer = new DataWriter(); uint dataSize = writer.MeasureString(data); writer.WriteUInt32(dataSize); writer.WriteString(data); IBuffer dataBuffer = writer.DetachBuffer(); var blobsToWrite = new Dictionary <string, IBuffer>(); blobsToWrite.Add(c_saveBlobName, dataBuffer); GameSaveOperationResult gameSaveOperationResult = await gameSaveContainer.SubmitUpdatesAsync(blobsToWrite, null, c_saveContainerDisplayName); //IReadOnlyDictionary<String, IBuffer> blobsToWrite //IEnumerable<string> blobsToDelete //string displayName Debug.WriteLine("XboxLiveConnectedStorage :: Saved Data - " + data); }
public async Task <GameSaveErrorStatus> SaveData(int data) { if (m_saveProvider == null) { throw new InvalidOperationException("The save system is not initialized."); } GameSaveContainer container = m_saveProvider.CreateContainer(c_saveContainerName); // To store a value in the container, it needs to be written into a buffer, then stored with // a blob name in a Dictionary. DataWriter writer = new DataWriter(); writer.WriteInt32(data); IBuffer dataBuffer = writer.DetachBuffer(); var updates = new Dictionary <string, IBuffer>(); updates.Add(c_saveBlobName, dataBuffer); GameSaveOperationResult result = await container.SubmitUpdatesAsync(updates, null, c_saveContainerDisplayName); return(result.Status); }