public void TestPostWhiteSpaceStringBody() { var connectClient = new LiveConnectClient(new LiveConnectSession()); try { connectClient.PutAsync("fileId.123", "\t\n "); Assert.Fail("Expected ArguementException to be thrown."); } catch (ArgumentException) { } }
public void TestPutWhiteSpaceStringPath() { var connectClient = new LiveConnectClient(new LiveConnectSession()); try { connectClient.PutAsync("\t\n ", new Dictionary <string, object>()); Assert.Fail("Expected ArguementException to be thrown."); } catch (ArgumentException) { } }
public async Task <dynamic> RenameSkyDriveItemAsync(String skyDriveItemId, String itemNewName) { // requires wl.skydrive_update scope var client = new LiveConnectClient(_session); var updateData = new Dictionary <String, Object> { { "name", itemNewName } }; var operationResult = await client.PutAsync(skyDriveItemId, updateData); dynamic result = operationResult.Result; return(result); }
public override async Task <IEntryModel> RenameAsync(IEntryModel entryModel, string newName, CancellationToken ct) { await _profile.checkLoginAsync(); var fileData = new Dictionary <string, object>(); fileData.Add("name", newName); LiveConnectClient liveClient = new LiveConnectClient(_profile.Session); LiveOperationResult result = await liveClient.PutAsync((entryModel as SkyDriveItemModel).UniqueId, fileData, ct); return(new SkyDriveItemModel(_profile, result.Result, entryModel.Parent.FullPath)); }
public void TestPutNullStringBody() { var connectClient = new LiveConnectClient(new LiveConnectSession()); try { string body = null; connectClient.PutAsync("fileId.123", body); Assert.Fail("Expected ArguementNullException to be thrown."); } catch (ArgumentNullException) { } }
public async Task <dynamic> UpdateCalendarEventAsync(String eventId, Dictionary <String, Object> updatedValues) { // requires wl.calendars_update if (updatedValues == null) { throw new ArgumentNullException("updatedValues"); } var client = new LiveConnectClient(_session); var operationResult = await client.PutAsync(eventId, updatedValues); dynamic result = operationResult.Result; return(result); }
/// <summary> /// http://msdn.microsoft.com/en-us/live/hh561740.aspx#updating_files_props /// The wl.skydrive_update scope is required. /// </summary> public void RenameFile() { if (session == null) { Debug.WriteLine("You must sign in first."); } else { Dictionary <string, object> fileData = new Dictionary <string, object>(); fileData.Add("name", "Grocery List 2.docx"); LiveConnectClient client = new LiveConnectClient(session); client.PutCompleted += new EventHandler <LiveOperationCompletedEventArgs>(RenameFile_Completed); client.PutAsync("file.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!119", fileData); } }
/// <summary> /// http://msdn.microsoft.com/en-us/live/hh561740.aspx#updating_folders /// The wl.skydrive_update scope is required. /// </summary> public void RenameFolder() { if (session == null) { Debug.WriteLine("You must sign in first."); } else { Dictionary <string, object> folderData = new Dictionary <string, object>(); folderData.Add("name", "This folder is renamed"); LiveConnectClient client = new LiveConnectClient(session); client.PutCompleted += new EventHandler <LiveOperationCompletedEventArgs>(RenameFolder_Completed); client.PutAsync("folder.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!145", folderData); } }
public async Task <bool> RenameFileInTrackTimerFolder(string existingFilePath, string newFileName) { LiveConnectSessionStatus connectStatus; if (client != null || (connectStatus = await Connect()) == LiveConnectSessionStatus.Connected) { // Upload to SkyDrive await FindTrackTimerFolder(client); var result = await client.PutAsync(existingFilePath, new Dictionary <string, object> { { "name", newFileName } }); return(true); } return(false); }
private async void RunButton_Click(object sender, RoutedEventArgs e) { try { // Validate parameters string path = pathTextBox.Text; string destination = destinationTextBox.Text; string requestBody = requestBodyTextBox.Text; var scope = (authScopesComboBox.SelectedValue as ComboBoxItem).Content as string; var method = (methodsComboBox.SelectedValue as ComboBoxItem).Content as string; // acquire auth permissions var authClient = new LiveAuthClient(); var authResult = await authClient.LoginAsync(new string[] { scope }); if (authResult.Session == null) { throw new InvalidOperationException("You need to login and give permission to the app."); } var liveConnectClient = new LiveConnectClient(authResult.Session); LiveOperationResult operationResult = null; switch (method) { case "GET": operationResult = await liveConnectClient.GetAsync(path); break; case "POST": operationResult = await liveConnectClient.PostAsync(path, requestBody); break; case "PUT": operationResult = await liveConnectClient.PutAsync(path, requestBody); break; case "DELETE": operationResult = await liveConnectClient.DeleteAsync(path); break; case "COPY": operationResult = await liveConnectClient.CopyAsync(path, destination); break; case "MOVE": operationResult = await liveConnectClient.MoveAsync(path, destination); break; } if (operationResult != null) { Log("Operation succeeded: \r\n" + operationResult.RawResult); } } catch (Exception ex) { Log("Got error: " + ex.Message); } }
public void TestPostWhiteSpaceStringBody() { var connectClient = new LiveConnectClient(new LiveConnectSession()); try { connectClient.PutAsync("fileId.123", "\t\n "); Assert.Fail("Expected ArguementException to be thrown."); } catch (ArgumentException) { } }
public void TestPutNullStringBody() { var connectClient = new LiveConnectClient(new LiveConnectSession()); try { string body = null; connectClient.PutAsync("fileId.123", body); Assert.Fail("Expected ArguementNullException to be thrown."); } catch (ArgumentNullException) { } }
public void TestPutWhiteSpaceStringPath() { var connectClient = new LiveConnectClient(new LiveConnectSession()); try { connectClient.PutAsync("\t\n ", new Dictionary<string, object>()); Assert.Fail("Expected ArguementException to be thrown."); } catch (ArgumentException) { } }