From 582f6319fec8f1d7e136cf5d5c39a998f23df34c Mon Sep 17 00:00:00 2001 From: Michael Mainer Date: Tue, 27 Feb 2018 13:52:12 -0800 Subject: [PATCH 01/19] Added nupsec --- Microsoft.Exchange.WebServices.Data.csproj | 49 ++++++++++++++++++---- Properties/AssemblyInfo.cs | 1 + Properties/AssemblyInfoOpenSource.cs | 4 +- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/Microsoft.Exchange.WebServices.Data.csproj b/Microsoft.Exchange.WebServices.Data.csproj index f4781e3f..ac7c1173 100644 --- a/Microsoft.Exchange.WebServices.Data.csproj +++ b/Microsoft.Exchange.WebServices.Data.csproj @@ -1,4 +1,4 @@ - + Debug @@ -868,13 +868,48 @@ true - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - --> + \ No newline at end of file diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 0d2e3425..8637cbd9 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,4 +32,5 @@ // COM Visible [assembly: ComVisible(false)] + // Friend Assemblies: Add to AssemblyInfoMicrosoft.cs \ No newline at end of file diff --git a/Properties/AssemblyInfoOpenSource.cs b/Properties/AssemblyInfoOpenSource.cs index b9e8e005..49fc6645 100644 --- a/Properties/AssemblyInfoOpenSource.cs +++ b/Properties/AssemblyInfoOpenSource.cs @@ -35,5 +35,5 @@ // Master branch will have version as 0.0.0.0, when a stable branch is created // this file will be updated with the appropriate version number and the release // will be built from there. -[assembly: AssemblyVersion("0.0.0.0")] -[assembly: AssemblyFileVersion("0.0.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.2.1")] +[assembly: AssemblyFileVersion("2.2.1.0")] \ No newline at end of file From a3209491c42b6082ff6885d8a20e575c5ada0585 Mon Sep 17 00:00:00 2001 From: Anton Vereshchak Date: Wed, 7 Mar 2018 17:17:30 +0200 Subject: [PATCH 02/19] Fix #163: ApplyConversationAction Multiple Items Bug Submit all conversation identifiers, not only the last one in conversation group actions. --- Core/ExchangeService.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Core/ExchangeService.cs b/Core/ExchangeService.cs index a93cd89c..99ff4a66 100644 --- a/Core/ExchangeService.cs +++ b/Core/ExchangeService.cs @@ -3705,7 +3705,7 @@ private ServiceResponseCollection ApplyConversationAction( actionType == ConversationActionType.AlwaysMove || actionType == ConversationActionType.AlwaysDelete, "ApplyConversationAction", - "Invalic actionType"); + "Invalid actionType"); EwsUtilities.ValidateParam(conversationIds, "conversationId"); EwsUtilities.ValidateMethodVersion( @@ -3714,16 +3714,18 @@ private ServiceResponseCollection ApplyConversationAction( "ApplyConversationAction"); ApplyConversationActionRequest request = new ApplyConversationActionRequest(this, errorHandlingMode); - ConversationAction action = new ConversationAction(); foreach (var conversationId in conversationIds) { + ConversationAction action = new ConversationAction(); + action.Action = actionType; action.ConversationId = conversationId; action.ProcessRightAway = processRightAway; action.Categories = categories; action.EnableAlwaysDelete = enableAlwaysDelete; action.DestinationFolderId = destinationFolderId != null ? new FolderIdWrapper(destinationFolderId) : null; + request.ConversationActions.Add(action); } From 8b33c1efae9cffbccfac7e7729b2af42a59d6f95 Mon Sep 17 00:00:00 2001 From: Wojciech Gomola Date: Mon, 19 Mar 2018 16:17:24 +0100 Subject: [PATCH 03/19] Proxy should be copied from template service --- Core/ExchangeServiceBase.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Core/ExchangeServiceBase.cs b/Core/ExchangeServiceBase.cs index 2d133f55..da3303a8 100644 --- a/Core/ExchangeServiceBase.cs +++ b/Core/ExchangeServiceBase.cs @@ -549,6 +549,7 @@ internal ExchangeServiceBase(ExchangeServiceBase service, ExchangeVersion reques this.timeZone = service.timeZone; this.httpHeaders = service.httpHeaders; this.ewsHttpWebRequestFactory = service.ewsHttpWebRequestFactory; + this.webProxy = service.webProxy; } /// From ddf92e1ed49e56cc85dfff9ec86cfa65fd1763a6 Mon Sep 17 00:00:00 2001 From: "Kasper F. Brandt" Date: Wed, 1 Nov 2017 20:18:11 +0100 Subject: [PATCH 04/19] Make XmlDtdException serializable --- Security/XmlDtdException.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Security/XmlDtdException.cs b/Security/XmlDtdException.cs index 19850e05..cfe38915 100644 --- a/Security/XmlDtdException.cs +++ b/Security/XmlDtdException.cs @@ -25,6 +25,7 @@ namespace Microsoft.Exchange.WebServices.Data { + using System.Runtime.Serialization; using System.Xml; /// @@ -39,5 +40,22 @@ public override string Message { get { return "For security reasons DTD is prohibited in this XML document."; } } + + /// + /// Initializes a new instance of the class. + /// + public XmlDtdException() + { + } + + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The that holds the serialized object data about the exception being thrown. + /// The that contains contextual information about the source or destination. + protected XmlDtdException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } } } \ No newline at end of file From 9da21586f75ee6a6c745248be5c849a8b94a5fe6 Mon Sep 17 00:00:00 2001 From: Ashish Date: Thu, 5 Apr 2018 14:07:38 +0530 Subject: [PATCH 05/19] Added DualAuthCredentials to manage dual auth with CBA + basic auth --- Credentials/DualAuthCredentials.cs | 75 ++++++++++++++++++++++ Microsoft.Exchange.WebServices.Data.csproj | 7 +- 2 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 Credentials/DualAuthCredentials.cs diff --git a/Credentials/DualAuthCredentials.cs b/Credentials/DualAuthCredentials.cs new file mode 100644 index 00000000..4723c13c --- /dev/null +++ b/Credentials/DualAuthCredentials.cs @@ -0,0 +1,75 @@ +/* +* Exchange Web Services Managed API +* +* Copyright(c) Microsoft Corporation +* All rights reserved. +* +* MIT License +* +* Permission is hereby granted, free of charge, to any person obtaining a copy of this +* software and associated documentation files (the "Software"), to deal in the Software +* without restriction, including without limitation the rights to use, copy, modify, merge, +* publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +* to whom the Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in all copies or +* substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +* PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +namespace Microsoft.Exchange.WebServices.Data.Credentials +{ + using System.Net; + using System.Security.Cryptography.X509Certificates; + + /// + /// DualAuthCredentials wraps an instance of X509CertificateCollection and basic auth credentials used for client dual authentication. + /// + public sealed class DualAuthCredentials : ExchangeCredentials + { + /// + /// Collection of client certificates. + /// + private X509CertificateCollection clientCertificates; + + private ICredentials credentials; + + /// + /// Initializes a new instance of the class. + /// + /// The client certificates. + /// The username. + /// The password. + public DualAuthCredentials(X509CertificateCollection clientCertificates, string userName, string password) + { + EwsUtilities.ValidateParam(clientCertificates, "clientCertificates"); + + this.clientCertificates = clientCertificates; + this.credentials = new NetworkCredential(userName, password); + } + + /// + /// This method is called to apply credentials to a service request before the request is made. + /// + /// The request. + internal override void PrepareWebRequest(IEwsHttpWebRequest request) + { + request.ClientCertificates = this.ClientCertificates; + request.Credentials = this.credentials; + } + + /// + /// Gets the client certificates collection. + /// + public X509CertificateCollection ClientCertificates + { + get { return this.clientCertificates; } + } + } +} \ No newline at end of file diff --git a/Microsoft.Exchange.WebServices.Data.csproj b/Microsoft.Exchange.WebServices.Data.csproj index 9eb88479..39f1a732 100644 --- a/Microsoft.Exchange.WebServices.Data.csproj +++ b/Microsoft.Exchange.WebServices.Data.csproj @@ -1,4 +1,4 @@ - + Debug @@ -108,6 +108,7 @@ + @@ -893,9 +894,9 @@ From 5c420ed3e7ddd7851629783639dce359b5ccc776 Mon Sep 17 00:00:00 2001 From: Michael Shenoda Date: Wed, 2 May 2018 13:47:56 -0700 Subject: [PATCH 06/19] If the time zone info doesn't support Daylight Saving Time for a specific year, we just need to create one transition to one group with one transition to the standard period. --- .../TimeZones/TimeZoneTransitionGroup.cs | 85 ++++++++++++------- 1 file changed, 52 insertions(+), 33 deletions(-) diff --git a/ComplexProperties/TimeZones/TimeZoneTransitionGroup.cs b/ComplexProperties/TimeZones/TimeZoneTransitionGroup.cs index c9f4f9e7..180130d3 100644 --- a/ComplexProperties/TimeZones/TimeZoneTransitionGroup.cs +++ b/ComplexProperties/TimeZones/TimeZoneTransitionGroup.cs @@ -118,39 +118,58 @@ internal override void WriteElementsToXml(EwsServiceXmlWriter writer) /// A reference to the pre-created standard period. internal virtual void InitializeFromAdjustmentRule(TimeZoneInfo.AdjustmentRule adjustmentRule, TimeZonePeriod standardPeriod) { - TimeZonePeriod daylightPeriod = new TimeZonePeriod(); - - // Generate an Id of the form "Daylight/2008" - daylightPeriod.Id = string.Format( - "{0}/{1}", - TimeZonePeriod.DaylightPeriodId, - adjustmentRule.DateStart.Year); - daylightPeriod.Name = TimeZonePeriod.DaylightPeriodName; - daylightPeriod.Bias = standardPeriod.Bias - adjustmentRule.DaylightDelta; - - this.timeZoneDefinition.Periods.Add(daylightPeriod.Id, daylightPeriod); - - this.transitionToDaylight = TimeZoneTransition.CreateTimeZoneTransition( - this.timeZoneDefinition, - daylightPeriod, - adjustmentRule.DaylightTransitionStart); - - TimeZonePeriod standardPeriodToSet = new TimeZonePeriod(); - standardPeriodToSet.Id = string.Format( - "{0}/{1}", - standardPeriod.Id, - adjustmentRule.DateStart.Year); - standardPeriodToSet.Name = standardPeriod.Name; - standardPeriodToSet.Bias = standardPeriod.Bias; - this.timeZoneDefinition.Periods.Add(standardPeriodToSet.Id, standardPeriodToSet); - - this.transitionToStandard = TimeZoneTransition.CreateTimeZoneTransition( - this.timeZoneDefinition, - standardPeriodToSet, - adjustmentRule.DaylightTransitionEnd); - - this.transitions.Add(this.transitionToDaylight); - this.transitions.Add(this.transitionToStandard); + if (adjustmentRule.DaylightDelta.TotalSeconds == 0) + { + // If the time zone info doesn't support Daylight Saving Time, we just need to + // create one transition to one group with one transition to the standard period. + TimeZonePeriod standardPeriodToSet = new TimeZonePeriod(); + standardPeriodToSet.Id = string.Format( + "{0}/{1}", + standardPeriod.Id, + adjustmentRule.DateStart.Year); + standardPeriodToSet.Name = standardPeriod.Name; + standardPeriodToSet.Bias = standardPeriod.Bias; + this.timeZoneDefinition.Periods.Add(standardPeriodToSet.Id, standardPeriodToSet); + + this.transitionToStandard = new TimeZoneTransition(this.timeZoneDefinition, standardPeriodToSet); + this.transitions.Add(this.transitionToStandard); + } + else + { + TimeZonePeriod daylightPeriod = new TimeZonePeriod(); + + // Generate an Id of the form "Daylight/2008" + daylightPeriod.Id = string.Format( + "{0}/{1}", + TimeZonePeriod.DaylightPeriodId, + adjustmentRule.DateStart.Year); + daylightPeriod.Name = TimeZonePeriod.DaylightPeriodName; + daylightPeriod.Bias = standardPeriod.Bias - adjustmentRule.DaylightDelta; + + this.timeZoneDefinition.Periods.Add(daylightPeriod.Id, daylightPeriod); + + this.transitionToDaylight = TimeZoneTransition.CreateTimeZoneTransition( + this.timeZoneDefinition, + daylightPeriod, + adjustmentRule.DaylightTransitionStart); + + TimeZonePeriod standardPeriodToSet = new TimeZonePeriod(); + standardPeriodToSet.Id = string.Format( + "{0}/{1}", + standardPeriod.Id, + adjustmentRule.DateStart.Year); + standardPeriodToSet.Name = standardPeriod.Name; + standardPeriodToSet.Bias = standardPeriod.Bias; + this.timeZoneDefinition.Periods.Add(standardPeriodToSet.Id, standardPeriodToSet); + + this.transitionToStandard = TimeZoneTransition.CreateTimeZoneTransition( + this.timeZoneDefinition, + standardPeriodToSet, + adjustmentRule.DaylightTransitionEnd); + + this.transitions.Add(this.transitionToDaylight); + this.transitions.Add(this.transitionToStandard); + } } /// From 01301b40eb11a1df9520fed0ba8c97646adb29ed Mon Sep 17 00:00:00 2001 From: "David Sterling (EXCHANGE)" Date: Thu, 5 Jul 2018 08:32:41 -0700 Subject: [PATCH 07/19] Add missing enum value for phoneNumberKey --- Enumerations/PhoneNumberKey.cs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/Enumerations/PhoneNumberKey.cs b/Enumerations/PhoneNumberKey.cs index 8614a9f7..ce905fb9 100644 --- a/Enumerations/PhoneNumberKey.cs +++ b/Enumerations/PhoneNumberKey.cs @@ -25,10 +25,6 @@ namespace Microsoft.Exchange.WebServices.Data { - using System; - using System.Collections.Generic; - using System.Text; - /// /// Defines phone number entries for a contact. /// @@ -127,6 +123,26 @@ public enum PhoneNumberKey /// /// The TTY/TTD phone number. /// - TtyTddPhone + TtyTddPhone, + + /// + /// Business mobile number. + /// + BusinessMobile, + + /// + /// IP Phone number. + /// + IPPhone, + + /// + /// Mms number. + /// + Mms, + + /// + /// Msn number. + /// + Msn } } \ No newline at end of file From 0298195d1c31ec8dcdceda7c857174af2197c56f Mon Sep 17 00:00:00 2001 From: Yina Arenas Date: Tue, 24 Jul 2018 17:49:01 -0700 Subject: [PATCH 08/19] Update README.md --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 29eb1af8..9527bfdd 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,11 @@ [![Gitter](https://badges.gitter.im/JoinChat.svg)](https://gitter.im/OfficeDev/ews-managed-api?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) The Exchange Web Services (EWS) Managed API provides a managed interface for developing .NET client applications that use EWS. -By using the EWS Managed API, you can access almost all the information stored in an Office 365, Exchange Online, or Exchange Server mailbox. +By using the EWS Managed API, you can access almost all the information stored in an Office 365, Exchange Online, or Exchange Server mailbox. However, this API is in sustaining mode, the recommended access pattern for Office 365 and Exchange online data is [Microsoft Graph] (https://graph.microsoft.com) + +## Support statement + +Starting July 19th 2918, Exchange Web Services (EWS) will no longer receive feature updates. While the service will continue to receive security updates and certain non-security updates, product design and features will remain unchanged. This change also applies to the EWS SDKs for Java and .NET. More information here: https://developer.microsoft.com/en-us/graph/blogs/upcoming-changes-to-exchange-web-services-ews-api-for-office-365/ ## Download options @@ -37,6 +41,6 @@ You need the following to work with the EWS Managed API: ## Community Exchange has an active developer community that you can turn to when you need help. We recommend using the [Exchange Server Development forum on MSDN](http://social.msdn.microsoft.com/Forums/en-US/home?category=exchangeserver&filter=alltypes&sort=lastpostdesc), or using the [ews] tag on [StackOverflow](http://stackoverflow.com/questions/tagged/ews). - - -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. + + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. From f186b4812e921503ecd896272c4429d07deccc49 Mon Sep 17 00:00:00 2001 From: Yina Arenas Date: Tue, 24 Jul 2018 17:56:50 -0700 Subject: [PATCH 09/19] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9527bfdd..aee3034b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Gitter](https://badges.gitter.im/JoinChat.svg)](https://gitter.im/OfficeDev/ews-managed-api?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) The Exchange Web Services (EWS) Managed API provides a managed interface for developing .NET client applications that use EWS. -By using the EWS Managed API, you can access almost all the information stored in an Office 365, Exchange Online, or Exchange Server mailbox. However, this API is in sustaining mode, the recommended access pattern for Office 365 and Exchange online data is [Microsoft Graph] (https://graph.microsoft.com) +By using the EWS Managed API, you can access almost all the information stored in an Office 365, Exchange Online, or Exchange Server mailbox. However, this API is in sustaining mode, the recommended access pattern for Office 365 and Exchange online data is [Microsoft Graph](https://graph.microsoft.com) ## Support statement From f93c38d9439f0afaf5d3a91194bfe6750c7c03b6 Mon Sep 17 00:00:00 2001 From: Yina Arenas Date: Tue, 24 Jul 2018 17:57:45 -0700 Subject: [PATCH 10/19] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aee3034b..097f05e9 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ By using the EWS Managed API, you can access almost all the information stored i ## Support statement -Starting July 19th 2918, Exchange Web Services (EWS) will no longer receive feature updates. While the service will continue to receive security updates and certain non-security updates, product design and features will remain unchanged. This change also applies to the EWS SDKs for Java and .NET. More information here: https://developer.microsoft.com/en-us/graph/blogs/upcoming-changes-to-exchange-web-services-ews-api-for-office-365/ +Starting July 19th 2018, Exchange Web Services (EWS) will no longer receive feature updates. While the service will continue to receive security updates and certain non-security updates, product design and features will remain unchanged. This change also applies to the EWS SDKs for Java and .NET. More information here: https://developer.microsoft.com/en-us/graph/blogs/upcoming-changes-to-exchange-web-services-ews-api-for-office-365/ ## Download options From aeb054aa6d68fbaf77e22d9498e1fa3ffec0f9bd Mon Sep 17 00:00:00 2001 From: sherlock1982 Date: Sat, 1 Sep 2018 21:53:50 +0300 Subject: [PATCH 11/19] get back ldap autodiscover --- Autodiscover/AutodiscoverService.cs | 5 ----- Microsoft.Exchange.WebServices.NETStandard.csproj | 12 ++++-------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/Autodiscover/AutodiscoverService.cs b/Autodiscover/AutodiscoverService.cs index e0eb33b5..69185f8c 100644 --- a/Autodiscover/AutodiscoverService.cs +++ b/Autodiscover/AutodiscoverService.cs @@ -1294,13 +1294,8 @@ private bool TryGetAutodiscoverEndpointUrl(string host, out Uri url) /// private ICollection DefaultGetScpUrlsForDomain(string domainName) { -#if NETSTANDARD2_0 - //todo: implement ldap autodiscover - return new string[0]; -#else DirectoryHelper helper = new DirectoryHelper(this); return helper.GetAutodiscoverScpUrlsForDomain(domainName); -#endif } /// diff --git a/Microsoft.Exchange.WebServices.NETStandard.csproj b/Microsoft.Exchange.WebServices.NETStandard.csproj index cf9b03e8..31da5d47 100644 --- a/Microsoft.Exchange.WebServices.NETStandard.csproj +++ b/Microsoft.Exchange.WebServices.NETStandard.csproj @@ -2,7 +2,7 @@ 1.1.3 - netstandard2.0;net46 + netstandard2.0;net461 Microsoft.Exchange.WebServices.NETStandard Microsoft.Exchange.WebServices.NETStandard false @@ -22,21 +22,16 @@ The Exchange Web Services (EWS) Managed API provides a managed interface for developing .NET client applications that use EWS. By using the EWS Managed API, you can access almost all the information stored in an Office 365, Exchange Online, or Exchange Server mailbox. - - - - - + - - 4.4.0 + 4.5.0 @@ -45,6 +40,7 @@ + From 00f2f5fdeb0f1c64b1c4882c7ead17ebc8a18a94 Mon Sep 17 00:00:00 2001 From: sherlock1982 Date: Sun, 2 Sep 2018 16:23:06 +0300 Subject: [PATCH 12/19] added CancellationToken for most of methods --- ComplexProperties/Attachment.cs | 11 +- ComplexProperties/AttachmentCollection.cs | 17 +- ComplexProperties/ItemAttachment.cs | 21 +- Core/EwsHttpWebRequest.cs | 5 +- Core/ExchangeService.cs | 819 +++++++++++------- .../Requests/DelegateManagementRequestBase.cs | 5 +- Core/Requests/DisableAppRequest.cs | 5 +- Core/Requests/DisconnectPhoneCallRequest.cs | 5 +- Core/Requests/FindConversationRequest.cs | 5 +- Core/Requests/FindPeopleRequest.cs | 5 +- Core/Requests/GetAppManifestsRequest.cs | 5 +- Core/Requests/GetAppMarketplaceUrlRequest.cs | 5 +- Core/Requests/GetClientExtensionRequest.cs | 5 +- .../GetDiscoverySearchConfigurationRequest.cs | 5 +- Core/Requests/GetHoldOnMailboxesRequest.cs | 5 +- Core/Requests/GetInboxRulesRequest.cs | 5 +- .../GetNonIndexableItemDetailsRequest.cs | 5 +- .../GetNonIndexableItemStatisticsRequest.cs | 5 +- Core/Requests/GetOMEConfigurationRequest.cs | 5 +- .../GetPasswordExpirationDateRequest.cs | 5 +- Core/Requests/GetPeopleInsightsRequest.cs | 5 +- Core/Requests/GetPhoneCallRequest.cs | 5 +- Core/Requests/GetRoomListsRequest.cs | 5 +- Core/Requests/GetRoomsRequest.cs | 5 +- .../Requests/GetSearchableMailboxesRequest.cs | 5 +- Core/Requests/GetUserAvailabilityRequest.cs | 5 +- Core/Requests/GetUserOofSettingsRequest.cs | 5 +- Core/Requests/GetUserPhotoRequest.cs | 5 +- .../GetUserRetentionPolicyTagsRequest.cs | 5 +- Core/Requests/HangingServiceRequestBase.cs | 4 +- Core/Requests/InstallAppRequest.cs | 5 +- Core/Requests/MultiResponseServiceRequest.cs | 5 +- Core/Requests/PlayOnPhoneRequest.cs | 5 +- Core/Requests/RegisterConsentRequest.cs | 5 +- Core/Requests/ServiceRequestBase.cs | 8 +- Core/Requests/SetHoldOnMailboxesRequest.cs | 5 +- Core/Requests/SetOMEConfigurationRequest.cs | 5 +- Core/Requests/SetTeamMailboxRequest.cs | 5 +- Core/Requests/SetUserOofSettingsRequest.cs | 5 +- Core/Requests/SetUserPhotoRequest.cs | 5 +- Core/Requests/SimpleServiceRequestBase.cs | 5 +- Core/Requests/UninstallAppRequest.cs | 5 +- Core/Requests/UnpinTeamMailboxRequest.cs | 5 +- Core/Requests/UpdateInboxRulesRequest.cs | 5 +- Core/ServiceObjects/Folders/CalendarFolder.cs | 11 +- Core/ServiceObjects/Folders/ContactsFolder.cs | 6 +- Core/ServiceObjects/Folders/Folder.cs | 85 +- Core/ServiceObjects/Folders/SearchFolder.cs | 6 +- Core/ServiceObjects/Folders/TasksFolder.cs | 6 +- Core/ServiceObjects/Items/Appointment.cs | 32 +- Core/ServiceObjects/Items/Contact.cs | 6 +- Core/ServiceObjects/Items/ContactGroup.cs | 6 +- Core/ServiceObjects/Items/Conversation.cs | 5 +- Core/ServiceObjects/Items/EmailMessage.cs | 41 +- Core/ServiceObjects/Items/Item.cs | 75 +- .../Items/MeetingCancellation.cs | 10 +- Core/ServiceObjects/Items/MeetingMessage.cs | 6 +- Core/ServiceObjects/Items/MeetingRequest.cs | 6 +- Core/ServiceObjects/Items/MeetingResponse.cs | 6 +- Core/ServiceObjects/Items/Persona.cs | 6 +- Core/ServiceObjects/Items/PostItem.cs | 6 +- Core/ServiceObjects/Items/Task.cs | 16 +- .../CalendarResponseMessageBase.cs | 29 +- .../ResponseObjects/PostReply.cs | 23 +- .../ResponseObjects/RemoveFromCalendar.cs | 11 +- .../ResponseObjects/ResponseObject.cs | 40 +- .../ResponseObjects/SuppressReadReceipt.cs | 11 +- Core/ServiceObjects/ServiceObject.cs | 14 +- .../GetUnifiedGroupUnseenCountRequest.cs | 5 +- .../Requests/GetUserUnifiedGroupsRequest.cs | 5 +- .../SetUnifiedGroupLastVisitedTimeRequest.cs | 5 +- Interfaces/IEwsHttpWebRequest.cs | 3 +- ...ft.Exchange.WebServices.NETStandard.csproj | 5 +- Misc/UserConfiguration.cs | 23 +- Notifications/PullSubscription.cs | 9 +- Notifications/StreamingSubscription.cs | 5 +- .../StreamingSubscriptionConnection.cs | 5 +- UnifiedMessaging/PhoneCall.cs | 9 +- UnifiedMessaging/UnifiedMessaging.cs | 13 +- 79 files changed, 962 insertions(+), 658 deletions(-) diff --git a/ComplexProperties/Attachment.cs b/ComplexProperties/Attachment.cs index 915f66c4..8345d0bf 100644 --- a/ComplexProperties/Attachment.cs +++ b/ComplexProperties/Attachment.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -304,12 +305,14 @@ internal override void WriteElementsToXml(EwsServiceXmlWriter writer) /// /// Type of the body. /// The additional properties. - internal Task> InternalLoad(BodyType? bodyType, IEnumerable additionalProperties) + internal Task> InternalLoad(BodyType? bodyType, IEnumerable additionalProperties, + CancellationToken token) { return this.service.GetAttachment( this, bodyType, - additionalProperties); + additionalProperties, + token); } /// @@ -323,9 +326,9 @@ internal virtual void Validate(int attachmentIndex) /// /// Loads the attachment. Calling this method results in a call to EWS. /// - public Task> Load() + public Task> Load(CancellationToken token = default(CancellationToken)) { - return this.InternalLoad(null, null); + return this.InternalLoad(null, null, token); } } } \ No newline at end of file diff --git a/ComplexProperties/AttachmentCollection.cs b/ComplexProperties/AttachmentCollection.cs index 5bc56aa0..15bed464 100644 --- a/ComplexProperties/AttachmentCollection.cs +++ b/ComplexProperties/AttachmentCollection.cs @@ -32,6 +32,7 @@ namespace Microsoft.Exchange.WebServices.Data using System.Linq; using System.Reflection; using System.Text; + using System.Threading; /// /// Represents an item's attachment collection. @@ -276,7 +277,7 @@ internal override string GetCollectionItemXmlElementName(Attachment complexPrope /// /// Saves this collection by creating new attachment and deleting removed ones. /// - internal async System.Threading.Tasks.Task Save() + internal async System.Threading.Tasks.Task Save(CancellationToken token = default(CancellationToken)) { List attachments = new List(); @@ -292,7 +293,7 @@ internal async System.Threading.Tasks.Task Save() // If any, delete them by calling the DeleteAttachment web method. if (attachments.Count > 0) { - await this.InternalDeleteAttachments(attachments); + await this.InternalDeleteAttachments(attachments, token); } attachments.Clear(); @@ -311,11 +312,11 @@ internal async System.Threading.Tasks.Task Save() { if (this.owner.IsAttachment) { - await this.InternalCreateAttachments(this.owner.ParentAttachment.Id, attachments); + await this.InternalCreateAttachments(this.owner.ParentAttachment.Id, attachments, token); } else { - await this.InternalCreateAttachments(this.owner.Id.UniqueId, attachments); + await this.InternalCreateAttachments(this.owner.Id.UniqueId, attachments, token); } } @@ -434,9 +435,9 @@ internal void Validate() /// Calls the DeleteAttachment web method to delete a list of attachments. /// /// The attachments to delete. - private async System.Threading.Tasks.Task InternalDeleteAttachments(IEnumerable attachments) + private async System.Threading.Tasks.Task InternalDeleteAttachments(IEnumerable attachments, CancellationToken token) { - ServiceResponseCollection responses = await this.owner.Service.DeleteAttachments(attachments); + ServiceResponseCollection responses = await this.owner.Service.DeleteAttachments(attachments, token); foreach (DeleteAttachmentResponse response in responses) { @@ -460,9 +461,9 @@ private async System.Threading.Tasks.Task InternalDeleteAttachments(IEnumerable< /// /// The Id of the parent item of the new attachments. /// The attachments to create. - private async System.Threading.Tasks.Task InternalCreateAttachments(string parentItemId, IEnumerable attachments) + private async System.Threading.Tasks.Task InternalCreateAttachments(string parentItemId, IEnumerable attachments, CancellationToken token) { - ServiceResponseCollection responses = await this.owner.Service.CreateAttachments(parentItemId, attachments); + ServiceResponseCollection responses = await this.owner.Service.CreateAttachments(parentItemId, attachments, token); foreach (CreateAttachmentResponse response in responses) { diff --git a/ComplexProperties/ItemAttachment.cs b/ComplexProperties/ItemAttachment.cs index e74d468b..c39a372f 100644 --- a/ComplexProperties/ItemAttachment.cs +++ b/ComplexProperties/ItemAttachment.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -184,22 +185,24 @@ internal override void Validate(int attachmentIndex) /// Loads this attachment. /// /// The optional additional properties to load. - public Task> Load(params PropertyDefinitionBase[] additionalProperties) + public Task> Load(CancellationToken token = default(CancellationToken), params PropertyDefinitionBase[] additionalProperties) { return this.InternalLoad( null /* bodyType */, - additionalProperties); + additionalProperties, + token); } /// /// Loads this attachment. /// /// The optional additional properties to load. - public Task> Load(IEnumerable additionalProperties) + public Task> Load(IEnumerable additionalProperties, CancellationToken token = default(CancellationToken)) { return this.InternalLoad( null /* bodyType */, - additionalProperties); + additionalProperties, + token); } /// @@ -207,11 +210,12 @@ public Task> Load(IEnumerable

/// The body type to load. /// The optional additional properties to load. - public Task> Load(BodyType bodyType, params PropertyDefinitionBase[] additionalProperties) + public Task> Load(BodyType bodyType, CancellationToken token = default(CancellationToken), params PropertyDefinitionBase[] additionalProperties) { return this.InternalLoad( bodyType, - additionalProperties); + additionalProperties, + token); } ///

@@ -219,11 +223,12 @@ public Task> Load(BodyType body /// /// The body type to load. /// The optional additional properties to load. - public Task> Load(BodyType bodyType, IEnumerable additionalProperties) + public Task> Load(BodyType bodyType, IEnumerable additionalProperties, CancellationToken token = default(CancellationToken)) { return this.InternalLoad( bodyType, - additionalProperties); + additionalProperties, + token); } } } \ No newline at end of file diff --git a/Core/EwsHttpWebRequest.cs b/Core/EwsHttpWebRequest.cs index c816378e..65a9c7b1 100644 --- a/Core/EwsHttpWebRequest.cs +++ b/Core/EwsHttpWebRequest.cs @@ -33,6 +33,7 @@ namespace Microsoft.Exchange.WebServices.Data using System.Net.Security; using System.Security.Cryptography.X509Certificates; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -84,7 +85,7 @@ public void Abort() /// /// A that contains the response from the Internet resource. /// - public async Task GetResponse() + public async Task GetResponse(CancellationToken token) { var message = new HttpRequestMessage(new HttpMethod(Method), RequestUri); message.Content = new StringContent(Content); @@ -106,7 +107,7 @@ public async Task GetResponse() HttpResponseMessage response = null; try { - response = await _httpClient.SendAsync(message); + response = await _httpClient.SendAsync(message, token); } catch(Exception exception) { diff --git a/Core/ExchangeService.cs b/Core/ExchangeService.cs index dcb18e2a..a1f3d4f6 100644 --- a/Core/ExchangeService.cs +++ b/Core/ExchangeService.cs @@ -39,6 +39,7 @@ namespace Microsoft.Exchange.WebServices.Data using Microsoft.Exchange.WebServices.Data.Enumerations; using Microsoft.Exchange.WebServices.Data.Groups; using System.Threading.Tasks; + using System.Threading; /// /// Represents a binding to the Exchange Web Services. @@ -79,7 +80,8 @@ public sealed class ExchangeService : ExchangeServiceBase internal async Task> InternalCreateResponseObject( ServiceObject responseObject, FolderId parentFolderId, - MessageDisposition? messageDisposition) + MessageDisposition? messageDisposition, + CancellationToken token) { CreateResponseObjectRequest request = new CreateResponseObjectRequest(this, ServiceErrorHandling.ThrowOnError); @@ -87,7 +89,7 @@ internal async Task> InternalCreateResponseObject( request.Items = new ServiceObject[] { responseObject }; request.MessageDisposition = messageDisposition; - ServiceResponseCollection responses = await request.ExecuteAsync().ConfigureAwait(false); + ServiceResponseCollection responses = await request.ExecuteAsync(token).ConfigureAwait(false); return responses[0].Items; } @@ -103,27 +105,27 @@ internal async Task> InternalCreateResponseObject( /// The parent folder id. internal System.Threading.Tasks.Task CreateFolder( Folder folder, - FolderId parentFolderId) + FolderId parentFolderId, CancellationToken token) { CreateFolderRequest request = new CreateFolderRequest(this, ServiceErrorHandling.ThrowOnError); request.Folders = new Folder[] { folder }; request.ParentFolderId = parentFolderId; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// /// Updates a folder. /// /// The folder. - internal System.Threading.Tasks.Task UpdateFolder(Folder folder) + internal System.Threading.Tasks.Task UpdateFolder(Folder folder, CancellationToken token) { UpdateFolderRequest request = new UpdateFolderRequest(this, ServiceErrorHandling.ThrowOnError); request.Folders.Add(folder); - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -134,14 +136,15 @@ internal System.Threading.Tasks.Task UpdateFolder(Folder folder) /// Copy of folder. internal async Task CopyFolder( FolderId folderId, - FolderId destinationFolderId) + FolderId destinationFolderId, + CancellationToken token) { CopyFolderRequest request = new CopyFolderRequest(this, ServiceErrorHandling.ThrowOnError); request.DestinationFolderId = destinationFolderId; request.FolderIds.Add(folderId); - ServiceResponseCollection responses = await request.ExecuteAsync().ConfigureAwait(false); + ServiceResponseCollection responses = await request.ExecuteAsync(token).ConfigureAwait(false); return responses[0].Folder; } @@ -154,14 +157,15 @@ internal async Task CopyFolder( /// Moved folder. internal async Task MoveFolder( FolderId folderId, - FolderId destinationFolderId) + FolderId destinationFolderId, + CancellationToken token) { MoveFolderRequest request = new MoveFolderRequest(this, ServiceErrorHandling.ThrowOnError); request.DestinationFolderId = destinationFolderId; request.FolderIds.Add(folderId); - ServiceResponseCollection responses = await request.ExecuteAsync().ConfigureAwait(false); + ServiceResponseCollection responses = await request.ExecuteAsync(token).ConfigureAwait(false); return responses[0].Folder; } @@ -180,7 +184,8 @@ private Task> InternalFindFolders( IEnumerable parentFolderIds, SearchFilter searchFilter, FolderView view, - ServiceErrorHandling errorHandlingMode) + ServiceErrorHandling errorHandlingMode, + CancellationToken token) { FindFolderRequest request = new FindFolderRequest(this, errorHandlingMode); @@ -188,7 +193,7 @@ private Task> InternalFindFolders( request.SearchFilter = searchFilter; request.View = view; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -200,7 +205,7 @@ private Task> InternalFindFolders( /// SearchFilter.SearchFilterCollection /// The view controlling the number of folders returned. /// An object representing the results of the search operation. - public async Task FindFolders(FolderId parentFolderId, SearchFilter searchFilter, FolderView view) + public async Task FindFolders(FolderId parentFolderId, SearchFilter searchFilter, FolderView view, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(parentFolderId, "parentFolderId"); EwsUtilities.ValidateParam(view, "view"); @@ -210,7 +215,7 @@ public async Task FindFolders(FolderId parentFolderId, Searc new FolderId[] { parentFolderId }, searchFilter, view, - ServiceErrorHandling.ThrowOnError).ConfigureAwait(false); + ServiceErrorHandling.ThrowOnError, token).ConfigureAwait(false); return responses[0].Results; } @@ -224,7 +229,8 @@ public async Task FindFolders(FolderId parentFolderId, Searc /// SearchFilter.SearchFilterCollection /// The view controlling the number of folders returned. /// An object representing the results of the search operation. - public Task> FindFolders(IEnumerable parentFolderIds, SearchFilter searchFilter, FolderView view) + public Task> FindFolders(IEnumerable parentFolderIds, SearchFilter searchFilter, FolderView view, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(parentFolderIds, "parentFolderIds"); EwsUtilities.ValidateParam(view, "view"); @@ -234,7 +240,8 @@ public Task> FindFolders(IEnumerab parentFolderIds, searchFilter, view, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -243,7 +250,7 @@ public Task> FindFolders(IEnumerab /// The Id of the folder in which to search for folders. /// The view controlling the number of folders returned. /// An object representing the results of the search operation. - public async Task FindFolders(FolderId parentFolderId, FolderView view) + public async Task FindFolders(FolderId parentFolderId, FolderView view, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(parentFolderId, "parentFolderId"); EwsUtilities.ValidateParam(view, "view"); @@ -252,7 +259,8 @@ public async Task FindFolders(FolderId parentFolderId, Folde new FolderId[] { parentFolderId }, null, /* searchFilter */ view, - ServiceErrorHandling.ThrowOnError).ConfigureAwait(false); + ServiceErrorHandling.ThrowOnError, + token).ConfigureAwait(false); return responses[0].Results; } @@ -289,7 +297,8 @@ public Task FindFolders(WellKnownFolderName parentFolderName /// The property set. internal Task> LoadPropertiesForFolder( Folder folder, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token) { EwsUtilities.ValidateParam(folder, "folder"); EwsUtilities.ValidateParam(propertySet, "propertySet"); @@ -299,7 +308,7 @@ internal Task> LoadPropertiesForFolde request.FolderIds.Add(folder); request.PropertySet = propertySet; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -308,7 +317,7 @@ internal Task> LoadPropertiesForFolde /// The folder id. /// The property set. /// Folder - internal async Task BindToFolder(FolderId folderId, PropertySet propertySet) + internal async Task BindToFolder(FolderId folderId, PropertySet propertySet, CancellationToken token) { EwsUtilities.ValidateParam(folderId, "folderId"); EwsUtilities.ValidateParam(propertySet, "propertySet"); @@ -316,7 +325,8 @@ internal async Task BindToFolder(FolderId folderId, PropertySet property ServiceResponseCollection responses = await this.InternalBindToFolders( new[] { folderId }, propertySet, - ServiceErrorHandling.ThrowOnError + ServiceErrorHandling.ThrowOnError, + token ); return responses[0].Folder; @@ -329,10 +339,10 @@ internal async Task BindToFolder(FolderId folderId, PropertySet property /// The folder id. /// The property set. /// Folder - internal async Task BindToFolder(FolderId folderId, PropertySet propertySet) + internal async Task BindToFolder(FolderId folderId, PropertySet propertySet, CancellationToken token) where TFolder : Folder { - Folder result = await this.BindToFolder(folderId, propertySet); + Folder result = await this.BindToFolder(folderId, propertySet, token); if (result is TFolder) { @@ -356,7 +366,8 @@ internal async Task BindToFolder(FolderId folderId, PropertySe /// A ServiceResponseCollection providing results for each of the specified folder Ids. public Task> BindToFolders( IEnumerable folderIds, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParamCollection(folderIds, "folderIds"); EwsUtilities.ValidateParam(propertySet, "propertySet"); @@ -364,7 +375,8 @@ public Task> BindToFolders( return this.InternalBindToFolders( folderIds, propertySet, - ServiceErrorHandling.ReturnErrors + ServiceErrorHandling.ReturnErrors, + token ); } @@ -378,14 +390,15 @@ public Task> BindToFolders( private Task> InternalBindToFolders( IEnumerable folderIds, PropertySet propertySet, - ServiceErrorHandling errorHandling) + ServiceErrorHandling errorHandling, + CancellationToken token) { GetFolderRequest request = new GetFolderRequest(this, errorHandling); request.FolderIds.AddRange(folderIds); request.PropertySet = propertySet; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -395,7 +408,8 @@ private Task> InternalBindToFolders /// The delete mode. internal Task> DeleteFolder( FolderId folderId, - DeleteMode deleteMode) + DeleteMode deleteMode, + CancellationToken token) { EwsUtilities.ValidateParam(folderId, "folderId"); @@ -404,7 +418,7 @@ internal Task> DeleteFolder( request.FolderIds.Add(folderId); request.DeleteMode = deleteMode; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -416,7 +430,8 @@ internal Task> DeleteFolder( internal Task> EmptyFolder( FolderId folderId, DeleteMode deleteMode, - bool deleteSubFolders) + bool deleteSubFolders, + CancellationToken token) { EwsUtilities.ValidateParam(folderId, "folderId"); @@ -426,7 +441,7 @@ internal Task> EmptyFolder( request.DeleteMode = deleteMode; request.DeleteSubFolders = deleteSubFolders; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -438,7 +453,8 @@ internal Task> EmptyFolder( internal Task> MarkAllItemsAsRead( FolderId folderId, bool readFlag, - bool suppressReadReceipts) + bool suppressReadReceipts, + CancellationToken token) { EwsUtilities.ValidateParam(folderId, "folderId"); EwsUtilities.ValidateMethodVersion(this, ExchangeVersion.Exchange2013, "MarkAllItemsAsRead"); @@ -449,7 +465,7 @@ internal Task> MarkAllItemsAsRead( request.ReadFlag = readFlag; request.SuppressReadReceipts = suppressReadReceipts; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } #endregion @@ -471,7 +487,8 @@ private Task> InternalCreateItems( FolderId parentFolderId, MessageDisposition? messageDisposition, SendInvitationsMode? sendInvitationsMode, - ServiceErrorHandling errorHandling) + ServiceErrorHandling errorHandling, + CancellationToken token) { CreateItemRequest request = new CreateItemRequest(this, errorHandling); @@ -480,7 +497,7 @@ private Task> InternalCreateItems( request.MessageDisposition = messageDisposition; request.SendInvitationsMode = sendInvitationsMode; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -496,7 +513,8 @@ public Task> CreateItems( IEnumerable items, FolderId parentFolderId, MessageDisposition? messageDisposition, - SendInvitationsMode? sendInvitationsMode) + SendInvitationsMode? sendInvitationsMode, + CancellationToken token = default(CancellationToken)) { // All items have to be new. if (!items.TrueForAll((item) => item.IsNew)) @@ -515,7 +533,8 @@ public Task> CreateItems( parentFolderId, messageDisposition, sendInvitationsMode, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -529,14 +548,16 @@ internal System.Threading.Tasks.Task CreateItem( Item item, FolderId parentFolderId, MessageDisposition? messageDisposition, - SendInvitationsMode? sendInvitationsMode) + SendInvitationsMode? sendInvitationsMode, + CancellationToken token) { return this.InternalCreateItems( new Item[] { item }, parentFolderId, messageDisposition, sendInvitationsMode, - ServiceErrorHandling.ThrowOnError); + ServiceErrorHandling.ThrowOnError, + token); } /// @@ -557,7 +578,8 @@ private Task> InternalUpdateItems( MessageDisposition? messageDisposition, SendInvitationsOrCancellationsMode? sendInvitationsOrCancellationsMode, ServiceErrorHandling errorHandling, - bool suppressReadReceipt) + bool suppressReadReceipt, + CancellationToken token) { UpdateItemRequest request = new UpdateItemRequest(this, errorHandling); @@ -568,7 +590,7 @@ private Task> InternalUpdateItems( request.SendInvitationsOrCancellationsMode = sendInvitationsOrCancellationsMode; request.SuppressReadReceipts = suppressReadReceipt; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -606,7 +628,8 @@ public Task> UpdateItems( ConflictResolutionMode conflictResolution, MessageDisposition? messageDisposition, SendInvitationsOrCancellationsMode? sendInvitationsOrCancellationsMode, - bool suppressReadReceipts) + bool suppressReadReceipts, + CancellationToken token = default(CancellationToken)) { // All items have to exist on the server (!new) and modified (dirty) if (!items.TrueForAll((item) => (!item.IsNew && item.IsDirty))) @@ -627,7 +650,8 @@ public Task> UpdateItems( messageDisposition, sendInvitationsOrCancellationsMode, ServiceErrorHandling.ReturnErrors, - suppressReadReceipts); + suppressReadReceipts, + token); } /// @@ -644,9 +668,10 @@ internal Task UpdateItem( FolderId savedItemsDestinationFolderId, ConflictResolutionMode conflictResolution, MessageDisposition? messageDisposition, - SendInvitationsOrCancellationsMode? sendInvitationsOrCancellationsMode) + SendInvitationsOrCancellationsMode? sendInvitationsOrCancellationsMode, + CancellationToken token) { - return this.UpdateItem(item, savedItemsDestinationFolderId, conflictResolution, messageDisposition, sendInvitationsOrCancellationsMode, false); + return this.UpdateItem(item, savedItemsDestinationFolderId, conflictResolution, messageDisposition, sendInvitationsOrCancellationsMode, false, token); } /// @@ -665,7 +690,8 @@ internal async Task UpdateItem( ConflictResolutionMode conflictResolution, MessageDisposition? messageDisposition, SendInvitationsOrCancellationsMode? sendInvitationsOrCancellationsMode, - bool suppressReadReceipts) + bool suppressReadReceipts, + CancellationToken token) { ServiceResponseCollection responses = await this.InternalUpdateItems( new Item[] { item }, @@ -674,7 +700,8 @@ internal async Task UpdateItem( messageDisposition, sendInvitationsOrCancellationsMode, ServiceErrorHandling.ThrowOnError, - suppressReadReceipts).ConfigureAwait(false); + suppressReadReceipts, + token).ConfigureAwait(false); return responses[0].ReturnedItem; } @@ -686,14 +713,15 @@ internal async Task UpdateItem( /// The saved copy destination folder id. internal System.Threading.Tasks.Task SendItem( Item item, - FolderId savedCopyDestinationFolderId) + FolderId savedCopyDestinationFolderId, + CancellationToken token) { SendItemRequest request = new SendItemRequest(this, ServiceErrorHandling.ThrowOnError); request.Items = new Item[] { item }; request.SavedCopyDestinationFolderId = savedCopyDestinationFolderId; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -708,14 +736,15 @@ private Task> InternalCopyItems( IEnumerable itemIds, FolderId destinationFolderId, bool? returnNewItemIds, - ServiceErrorHandling errorHandling) + ServiceErrorHandling errorHandling, + CancellationToken token) { CopyItemRequest request = new CopyItemRequest(this, errorHandling); request.ItemIds.AddRange(itemIds); request.DestinationFolderId = destinationFolderId; request.ReturnNewItemIds = returnNewItemIds; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -726,13 +755,15 @@ private Task> InternalCopyItems( /// A ServiceResponseCollection providing copy results for each of the specified item Ids. public Task> CopyItems( IEnumerable itemIds, - FolderId destinationFolderId) + FolderId destinationFolderId, + CancellationToken token = default(CancellationToken)) { return this.InternalCopyItems( itemIds, destinationFolderId, null, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -745,7 +776,8 @@ public Task> CopyItems( public Task> CopyItems( IEnumerable itemIds, FolderId destinationFolderId, - bool returnNewItemIds) + bool returnNewItemIds, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateMethodVersion( this, @@ -756,7 +788,8 @@ public Task> CopyItems( itemIds, destinationFolderId, returnNewItemIds, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -767,13 +800,15 @@ public Task> CopyItems( /// The copy of the item. internal async Task CopyItem( ItemId itemId, - FolderId destinationFolderId) + FolderId destinationFolderId, + CancellationToken token) { return (await this.InternalCopyItems( new ItemId[] { itemId }, destinationFolderId, null, - ServiceErrorHandling.ThrowOnError).ConfigureAwait(false))[0].Item; + ServiceErrorHandling.ThrowOnError, + token).ConfigureAwait(false))[0].Item; } /// @@ -788,7 +823,8 @@ private Task> InternalMoveItems( IEnumerable itemIds, FolderId destinationFolderId, bool? returnNewItemIds, - ServiceErrorHandling errorHandling) + ServiceErrorHandling errorHandling, + CancellationToken token) { MoveItemRequest request = new MoveItemRequest(this, errorHandling); @@ -796,7 +832,7 @@ private Task> InternalMoveItems( request.DestinationFolderId = destinationFolderId; request.ReturnNewItemIds = returnNewItemIds; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -807,13 +843,15 @@ private Task> InternalMoveItems( /// A ServiceResponseCollection providing copy results for each of the specified item Ids. public Task> MoveItems( IEnumerable itemIds, - FolderId destinationFolderId) + FolderId destinationFolderId, + CancellationToken token = default(CancellationToken)) { return this.InternalMoveItems( itemIds, destinationFolderId, null, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -826,7 +864,8 @@ public Task> MoveItems( public Task> MoveItems( IEnumerable itemIds, FolderId destinationFolderId, - bool returnNewItemIds) + bool returnNewItemIds, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateMethodVersion( this, @@ -837,7 +876,8 @@ public Task> MoveItems( itemIds, destinationFolderId, returnNewItemIds, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -848,13 +888,15 @@ public Task> MoveItems( /// The moved item. internal async Task MoveItem( ItemId itemId, - FolderId destinationFolderId) + FolderId destinationFolderId, + CancellationToken token) { return (await this.InternalMoveItems( new ItemId[] { itemId }, destinationFolderId, null, - ServiceErrorHandling.ThrowOnError).ConfigureAwait(false))[0].Item; + ServiceErrorHandling.ThrowOnError, + token).ConfigureAwait(false))[0].Item; } /// @@ -865,14 +907,15 @@ internal async Task MoveItem( /// A ServiceResponseCollection providing copy results for each of the specified item Ids. public Task> ArchiveItems( IEnumerable itemIds, - FolderId sourceFolderId) + FolderId sourceFolderId, + CancellationToken token = default(CancellationToken)) { ArchiveItemRequest request = new ArchiveItemRequest(this, ServiceErrorHandling.ReturnErrors); request.Ids.AddRange(itemIds); request.SourceFolderId = sourceFolderId; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -894,7 +937,8 @@ internal Task>> FindItems>> FindItems @@ -921,7 +965,7 @@ internal Task>> FindItemsthe search string to be used for indexed search, if any. /// The view controlling the number of items returned. /// An object representing the results of the search operation. - public async Task> FindItems(FolderId parentFolderId, string queryString, ViewBase view) + public async Task> FindItems(FolderId parentFolderId, string queryString, ViewBase view, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParamAllowNull(queryString, "queryString"); @@ -931,7 +975,8 @@ public async Task> FindItems(FolderId parentFolderId, str queryString, view, null, /* groupBy */ - ServiceErrorHandling.ThrowOnError).ConfigureAwait(false); + ServiceErrorHandling.ThrowOnError, + token).ConfigureAwait(false); return responses[0].Results; } @@ -946,7 +991,8 @@ public async Task> FindItems(FolderId parentFolderId, str /// Flag indicating if highlight terms should be returned in the response /// The view controlling the number of items returned. /// An object representing the results of the search operation. - public async Task> FindItems(FolderId parentFolderId, string queryString, bool returnHighlightTerms, ViewBase view) + public async Task> FindItems(FolderId parentFolderId, string queryString, bool returnHighlightTerms, ViewBase view, + CancellationToken token = default(CancellationToken)) { FolderId[] parentFolderIds = new FolderId[] { parentFolderId }; @@ -963,7 +1009,7 @@ public async Task> FindItems(FolderId parentFolderId, str request.ReturnHighlightTerms = returnHighlightTerms; request.View = view; - ServiceResponseCollection> responses = await request.ExecuteAsync().ConfigureAwait(false); + ServiceResponseCollection> responses = await request.ExecuteAsync(token).ConfigureAwait(false); return responses[0].Results; } @@ -978,7 +1024,7 @@ public async Task> FindItems(FolderId parentFolderId, str /// The view controlling the number of items returned. /// The group by clause. /// An object representing the results of the search operation. - public async Task> FindItems(FolderId parentFolderId, string queryString, bool returnHighlightTerms, ViewBase view, Grouping groupBy) + public async Task> FindItems(FolderId parentFolderId, string queryString, bool returnHighlightTerms, ViewBase view, Grouping groupBy, CancellationToken token = default(CancellationToken)) { FolderId[] parentFolderIds = new FolderId[] { parentFolderId }; @@ -997,7 +1043,7 @@ public async Task> FindItems(FolderId parentFolder request.View = view; request.GroupBy = groupBy; - ServiceResponseCollection> responses = await request.ExecuteAsync().ConfigureAwait(false); + ServiceResponseCollection> responses = await request.ExecuteAsync(token).ConfigureAwait(false); return responses[0].GroupedFindResults; } @@ -1010,7 +1056,7 @@ public async Task> FindItems(FolderId parentFolder /// SearchFilter.SearchFilterCollection /// The view controlling the number of items returned. /// An object representing the results of the search operation. - public async Task> FindItems(FolderId parentFolderId, SearchFilter searchFilter, ViewBase view) + public async Task> FindItems(FolderId parentFolderId, SearchFilter searchFilter, ViewBase view, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParamAllowNull(searchFilter, "searchFilter"); @@ -1020,7 +1066,8 @@ public async Task> FindItems(FolderId parentFolderId, Sea null, /* queryString */ view, null, /* groupBy */ - ServiceErrorHandling.ThrowOnError).ConfigureAwait(false); + ServiceErrorHandling.ThrowOnError, + token).ConfigureAwait(false); return responses[0].Results; } @@ -1031,7 +1078,7 @@ public async Task> FindItems(FolderId parentFolderId, Sea /// The Id of the folder in which to search for items. /// The view controlling the number of items returned. /// An object representing the results of the search operation. - public async Task> FindItems(FolderId parentFolderId, ViewBase view) + public async Task> FindItems(FolderId parentFolderId, ViewBase view, CancellationToken token = default(CancellationToken)) { ServiceResponseCollection> responses = await this.FindItems( new FolderId[] { parentFolderId }, @@ -1039,7 +1086,8 @@ public async Task> FindItems(FolderId parentFolderId, Vie null, /* queryString */ view, null, /* groupBy */ - ServiceErrorHandling.ThrowOnError).ConfigureAwait(false); + ServiceErrorHandling.ThrowOnError, + token).ConfigureAwait(false); return responses[0].Results; } @@ -1079,12 +1127,13 @@ public Task> FindItems(WellKnownFolderName parentFolderNa /// The name of the folder in which to search for items. /// The view controlling the number of items returned. /// An object representing the results of the search operation. - public Task> FindItems(WellKnownFolderName parentFolderName, ViewBase view) + public Task> FindItems(WellKnownFolderName parentFolderName, ViewBase view, CancellationToken token = default(CancellationToken)) { return this.FindItems( new FolderId(parentFolderName), (SearchFilter)null, - view); + view, + token); } /// @@ -1099,7 +1148,8 @@ public async Task> FindItems( FolderId parentFolderId, string queryString, ViewBase view, - Grouping groupBy) + Grouping groupBy, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(groupBy, "groupBy"); EwsUtilities.ValidateParamAllowNull(queryString, "queryString"); @@ -1110,7 +1160,8 @@ public async Task> FindItems( queryString, view, groupBy, - ServiceErrorHandling.ThrowOnError).ConfigureAwait(false); + ServiceErrorHandling.ThrowOnError, + token).ConfigureAwait(false); return responses[0].GroupedFindResults; } @@ -1129,7 +1180,8 @@ public async Task> FindItems( FolderId parentFolderId, SearchFilter searchFilter, ViewBase view, - Grouping groupBy) + Grouping groupBy, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(groupBy, "groupBy"); EwsUtilities.ValidateParamAllowNull(searchFilter, "searchFilter"); @@ -1140,7 +1192,8 @@ public async Task> FindItems( null, /* queryString */ view, groupBy, - ServiceErrorHandling.ThrowOnError).ConfigureAwait(false); + ServiceErrorHandling.ThrowOnError, + token).ConfigureAwait(false); return responses[0].GroupedFindResults; } @@ -1155,7 +1208,8 @@ public async Task> FindItems( public async Task> FindItems( FolderId parentFolderId, ViewBase view, - Grouping groupBy) + Grouping groupBy, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(groupBy, "groupBy"); @@ -1165,7 +1219,8 @@ public async Task> FindItems( null, /* queryString */ view, groupBy, - ServiceErrorHandling.ThrowOnError).ConfigureAwait(false); + ServiceErrorHandling.ThrowOnError, + token).ConfigureAwait(false); return responses[0].GroupedFindResults; } @@ -1185,7 +1240,8 @@ internal Task>> FindItems( @@ -1194,7 +1250,8 @@ internal Task>> FindItems @@ -1209,7 +1266,8 @@ public Task> FindItems( WellKnownFolderName parentFolderName, string queryString, ViewBase view, - Grouping groupBy) + Grouping groupBy, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(groupBy, "groupBy"); @@ -1217,7 +1275,8 @@ public Task> FindItems( new FolderId(parentFolderName), queryString, view, - groupBy); + groupBy, + token); } /// @@ -1234,13 +1293,15 @@ public Task> FindItems( WellKnownFolderName parentFolderName, SearchFilter searchFilter, ViewBase view, - Grouping groupBy) + Grouping groupBy, + CancellationToken token = default(CancellationToken)) { return this.FindItems( new FolderId(parentFolderName), searchFilter, view, - groupBy); + groupBy, + token); } /// @@ -1249,7 +1310,7 @@ public Task> FindItems( /// The id of the calendar folder in which to search for items. /// The calendar view controlling the number of appointments returned. /// A collection of appointments representing the contents of the specified folder. - public async Task> FindAppointments(FolderId parentFolderId, CalendarView calendarView) + public async Task> FindAppointments(FolderId parentFolderId, CalendarView calendarView, CancellationToken token = default(CancellationToken)) { ServiceResponseCollection> response = await this.FindItems( new FolderId[] { parentFolderId }, @@ -1257,7 +1318,8 @@ public async Task> FindAppointments(FolderId paren null, /* queryString */ calendarView, null, /* groupBy */ - ServiceErrorHandling.ThrowOnError).ConfigureAwait(false); + ServiceErrorHandling.ThrowOnError, + token).ConfigureAwait(false); return response[0].Results; } @@ -1268,9 +1330,9 @@ public async Task> FindAppointments(FolderId paren /// The name of the calendar folder in which to search for items. /// The calendar view controlling the number of appointments returned. /// A collection of appointments representing the contents of the specified folder. - public Task> FindAppointments(WellKnownFolderName parentFolderName, CalendarView calendarView) + public Task> FindAppointments(WellKnownFolderName parentFolderName, CalendarView calendarView, CancellationToken token = default(CancellationToken)) { - return this.FindAppointments(new FolderId(parentFolderName), calendarView); + return this.FindAppointments(new FolderId(parentFolderName), calendarView, token); } /// @@ -1279,7 +1341,7 @@ public Task> FindAppointments(WellKnownFolderName /// The items to load the properties of. /// The set of properties to load. /// A ServiceResponseCollection providing results for each of the specified items. - public Task> LoadPropertiesForItems(IEnumerable items, PropertySet propertySet) + public Task> LoadPropertiesForItems(IEnumerable items, PropertySet propertySet, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParamCollection(items, "items"); EwsUtilities.ValidateParam(propertySet, "propertySet"); @@ -1287,7 +1349,8 @@ public Task> LoadPropertiesForItems(I return this.InternalLoadPropertiesForItems( items, propertySet, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -1300,14 +1363,15 @@ public Task> LoadPropertiesForItems(I internal Task> InternalLoadPropertiesForItems( IEnumerable items, PropertySet propertySet, - ServiceErrorHandling errorHandling) + ServiceErrorHandling errorHandling, + CancellationToken token) { GetItemRequestForLoad request = new GetItemRequestForLoad(this, errorHandling); request.ItemIds.AddRange(items); request.PropertySet = propertySet; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -1322,7 +1386,8 @@ private Task> InternalBindToItems( IEnumerable itemIds, PropertySet propertySet, string anchorMailbox, - ServiceErrorHandling errorHandling) + ServiceErrorHandling errorHandling, + CancellationToken token) { GetItemRequest request = new GetItemRequest(this, errorHandling); @@ -1330,7 +1395,7 @@ private Task> InternalBindToItems( request.PropertySet = propertySet; request.AnchorMailbox = anchorMailbox; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -1339,7 +1404,7 @@ private Task> InternalBindToItems( /// The Ids of the items to bind to. /// The set of properties to load. /// A ServiceResponseCollection providing results for each of the specified item Ids. - public Task> BindToItems(IEnumerable itemIds, PropertySet propertySet) + public Task> BindToItems(IEnumerable itemIds, PropertySet propertySet, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParamCollection(itemIds, "itemIds"); EwsUtilities.ValidateParam(propertySet, "propertySet"); @@ -1348,7 +1413,8 @@ public Task> BindToItems(IEnumerable< itemIds, propertySet, null, /* anchorMailbox */ - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -1365,7 +1431,8 @@ public Task> BindToItems(IEnumerable< public Task> BindToGroupItems( IEnumerable itemIds, PropertySet propertySet, - string anchorMailbox) + string anchorMailbox, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParamCollection(itemIds, "itemIds"); EwsUtilities.ValidateParam(propertySet, "propertySet"); @@ -1375,7 +1442,8 @@ public Task> BindToGroupItems( itemIds, propertySet, anchorMailbox, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -1384,7 +1452,7 @@ public Task> BindToGroupItems( /// The item id. /// The property set. /// Item. - internal async Task BindToItem(ItemId itemId, PropertySet propertySet) + internal async Task BindToItem(ItemId itemId, PropertySet propertySet, CancellationToken token) { EwsUtilities.ValidateParam(itemId, "itemId"); EwsUtilities.ValidateParam(propertySet, "propertySet"); @@ -1393,7 +1461,8 @@ internal async Task BindToItem(ItemId itemId, PropertySet propertySet) new ItemId[] { itemId }, propertySet, null, /* anchorMailbox */ - ServiceErrorHandling.ThrowOnError).ConfigureAwait(false); + ServiceErrorHandling.ThrowOnError, + token).ConfigureAwait(false); return responses[0].Item; } @@ -1405,10 +1474,10 @@ internal async Task BindToItem(ItemId itemId, PropertySet propertySet) /// The item id. /// The property set. /// Item - internal async Task BindToItem(ItemId itemId, PropertySet propertySet) + internal async Task BindToItem(ItemId itemId, PropertySet propertySet, CancellationToken token) where TItem : Item { - Item result = await this.BindToItem(itemId, propertySet).ConfigureAwait(false); + Item result = await this.BindToItem(itemId, propertySet, token).ConfigureAwait(false); if (result is TItem) { @@ -1440,7 +1509,8 @@ private Task> InternalDeleteItems( SendCancellationsMode? sendCancellationsMode, AffectedTaskOccurrence? affectedTaskOccurrences, ServiceErrorHandling errorHandling, - bool suppressReadReceipts) + bool suppressReadReceipts, + CancellationToken token) { DeleteItemRequest request = new DeleteItemRequest(this, errorHandling); @@ -1450,7 +1520,7 @@ private Task> InternalDeleteItems( request.AffectedTaskOccurrences = affectedTaskOccurrences; request.SuppressReadReceipts = suppressReadReceipts; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -1484,7 +1554,8 @@ public Task> DeleteItems( DeleteMode deleteMode, SendCancellationsMode? sendCancellationsMode, AffectedTaskOccurrence? affectedTaskOccurrences, - bool suppressReadReceipt) + bool suppressReadReceipt, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParamCollection(itemIds, "itemIds"); @@ -1494,7 +1565,8 @@ public Task> DeleteItems( sendCancellationsMode, affectedTaskOccurrences, ServiceErrorHandling.ReturnErrors, - suppressReadReceipt); + suppressReadReceipt, + token); } /// @@ -1508,9 +1580,10 @@ internal Task> DeleteItem( ItemId itemId, DeleteMode deleteMode, SendCancellationsMode? sendCancellationsMode, - AffectedTaskOccurrence? affectedTaskOccurrences) + AffectedTaskOccurrence? affectedTaskOccurrences, + CancellationToken token) { - return this.DeleteItem(itemId, deleteMode, sendCancellationsMode, affectedTaskOccurrences, false); + return this.DeleteItem(itemId, deleteMode, sendCancellationsMode, affectedTaskOccurrences, false, token); } /// @@ -1526,7 +1599,8 @@ internal Task> DeleteItem( DeleteMode deleteMode, SendCancellationsMode? sendCancellationsMode, AffectedTaskOccurrence? affectedTaskOccurrences, - bool suppressReadReceipts) + bool suppressReadReceipts, + CancellationToken token) { EwsUtilities.ValidateParam(itemId, "itemId"); @@ -1536,7 +1610,8 @@ internal Task> DeleteItem( sendCancellationsMode, affectedTaskOccurrences, ServiceErrorHandling.ThrowOnError, - suppressReadReceipts); + suppressReadReceipts, + token); } /// @@ -1546,13 +1621,14 @@ internal Task> DeleteItem( /// Whether the items are junk. If true, senders are add to blocked sender list. If false, senders are removed. /// Whether to move the item. Items are moved to junk folder if isJunk is true, inbox if isJunk is false. /// A ServiceResponseCollection providing itemIds for each of the moved items.. - public Task> MarkAsJunk(IEnumerable itemIds, bool isJunk, bool moveItem) + public Task> MarkAsJunk(IEnumerable itemIds, bool isJunk, bool moveItem, + CancellationToken token = default(CancellationToken)) { MarkAsJunkRequest request = new MarkAsJunkRequest(this, ServiceErrorHandling.ReturnErrors); request.ItemIds.AddRange(itemIds); request.IsJunk = isJunk; request.MoveItem = moveItem; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } #endregion @@ -1569,7 +1645,8 @@ public Task> MarkAsJunk(IEnumerabl /// The view which defines the number of persona being returned /// The query string for which the search is being performed /// A collection of personas matching the search conditions - public async Task> FindPeople(FolderId folderId, SearchFilter searchFilter, ViewBase view, string queryString) + public async Task> FindPeople(FolderId folderId, SearchFilter searchFilter, ViewBase view, string queryString, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParamAllowNull(folderId, "folderId"); EwsUtilities.ValidateParamAllowNull(searchFilter, "searchFilter"); @@ -1584,7 +1661,7 @@ public async Task> FindPeople(FolderId folderId, SearchFilt request.View = view; request.QueryString = queryString; - return (await request.Execute().ConfigureAwait(false)).Personas; + return (await request.Execute(token).ConfigureAwait(false)).Personas; } /// @@ -1610,7 +1687,8 @@ public Task> FindPeople(WellKnownFolderName folderName, Sea /// Search filter /// The view which defines paging and the number of persona being returned /// A result object containing resultset for browsing - public async Task FindPeople(FolderId folderId, SearchFilter searchFilter, ViewBase view) + public async Task FindPeople(FolderId folderId, SearchFilter searchFilter, ViewBase view, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParamAllowNull(folderId, "folderId"); EwsUtilities.ValidateParamAllowNull(searchFilter, "searchFilter"); @@ -1623,7 +1701,7 @@ public async Task FindPeople(FolderId folderId, SearchFilter request.SearchFilter = searchFilter; request.View = view; - return (await request.Execute().ConfigureAwait(false)).Results; + return (await request.Execute(token).ConfigureAwait(false)).Results; } /// @@ -1655,9 +1733,9 @@ public Task BrowsePeople(ViewBase view) /// The view which defines the number of personas being returned /// The context for this query. See PeopleQueryContextKeys for keys /// A collection of personas matching the query string - public Task BrowsePeople(ViewBase view, Dictionary context) + public Task BrowsePeople(ViewBase view, Dictionary context, CancellationToken token = default(CancellationToken)) { - return this.PerformPeopleQuery(view, string.Empty, context, null); + return this.PerformPeopleQuery(view, string.Empty, context, null, token); } /// @@ -1680,11 +1758,11 @@ public Task SearchPeople(ViewBase view, string queryString) /// The context for this query. See PeopleQueryContextKeys for keys /// The scope of the query. /// A collection of personas matching the query string - public Task SearchPeople(ViewBase view, string queryString, Dictionary context, PeopleQueryMode queryMode) + public Task SearchPeople(ViewBase view, string queryString, Dictionary context, PeopleQueryMode queryMode, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(queryString, "queryString"); - return this.PerformPeopleQuery(view, queryString, context, queryMode); + return this.PerformPeopleQuery(view, queryString, context, queryMode, token); } /// @@ -1695,7 +1773,7 @@ public Task SearchPeople(ViewBase view, string queryString, /// The context for this query /// The scope of the query. /// - private async Task PerformPeopleQuery(ViewBase view, string queryString, Dictionary context, PeopleQueryMode queryMode) + private async Task PerformPeopleQuery(ViewBase view, string queryString, Dictionary context, PeopleQueryMode queryMode, CancellationToken token) { EwsUtilities.ValidateParam(view, "view"); EwsUtilities.ValidateMethodVersion(this, ExchangeVersion.Exchange2015, "FindPeople"); @@ -1717,7 +1795,7 @@ private async Task PerformPeopleQuery(ViewBase view, string request.Context = context; request.QueryMode = queryMode; - FindPeopleResponse response = await request.Execute().ConfigureAwait(false); + FindPeopleResponse response = await request.Execute(token).ConfigureAwait(false); PeopleQueryResults results = new PeopleQueryResults(); results.Personas = response.Personas.ToList(); @@ -1733,7 +1811,8 @@ private async Task PerformPeopleQuery(ViewBase view, string /// The desired size of the returned photo. Valid photo sizes are in UserPhotoSize /// A photo's cache ID which will allow the caller to ensure their cached photo is up to date /// A result object containing the photo state - public async Task GetUserPhoto(string emailAddress, string userPhotoSize, string entityTag) + public async Task GetUserPhoto(string emailAddress, string userPhotoSize, string entityTag, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(emailAddress, "emailAddress"); EwsUtilities.ValidateParam(userPhotoSize, "userPhotoSize"); @@ -1745,7 +1824,7 @@ public async Task GetUserPhoto(string emailAddress, string request.UserPhotoSize = userPhotoSize; request.EntityTag = entityTag; - return (await request.Execute().ConfigureAwait(false)).Results; + return (await request.Execute(token).ConfigureAwait(false)).Results; } #endregion @@ -1757,12 +1836,12 @@ public async Task GetUserPhoto(string emailAddress, string /// /// Specified eamiladdresses to retrieve /// The collection of Person objects containing the insight info - public async Task> GetPeopleInsights(IEnumerable emailAddresses) + public async Task> GetPeopleInsights(IEnumerable emailAddresses, CancellationToken token = default(CancellationToken)) { GetPeopleInsightsRequest request = new GetPeopleInsightsRequest(this); request.Emailaddresses.AddRange(emailAddresses); - return (await request.Execute().ConfigureAwait(false)).People; + return (await request.Execute(token).ConfigureAwait(false)).People; } #endregion @@ -1780,7 +1859,8 @@ private Task> InternalGetAttach IEnumerable attachments, BodyType? bodyType, IEnumerable additionalProperties, - ServiceErrorHandling errorHandling) + ServiceErrorHandling errorHandling, + CancellationToken token) { GetAttachmentRequest request = new GetAttachmentRequest(this, errorHandling); @@ -1792,7 +1872,7 @@ private Task> InternalGetAttach request.AdditionalProperties.AddRange(additionalProperties); } - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -1805,13 +1885,15 @@ private Task> InternalGetAttach public Task> GetAttachments( Attachment[] attachments, BodyType? bodyType, - IEnumerable additionalProperties) + IEnumerable additionalProperties, + CancellationToken token = default(CancellationToken)) { return this.InternalGetAttachments( attachments, bodyType, additionalProperties, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -1824,7 +1906,8 @@ public Task> GetAttachments( public Task> GetAttachments( string[] attachmentIds, BodyType? bodyType, - IEnumerable additionalProperties) + IEnumerable additionalProperties, + CancellationToken token = default(CancellationToken)) { GetAttachmentRequest request = new GetAttachmentRequest(this, ServiceErrorHandling.ReturnErrors); @@ -1836,7 +1919,7 @@ public Task> GetAttachments( request.AdditionalProperties.AddRange(additionalProperties); } - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -1848,13 +1931,15 @@ public Task> GetAttachments( internal Task> GetAttachment( Attachment attachment, BodyType? bodyType, - IEnumerable additionalProperties) + IEnumerable additionalProperties, + CancellationToken token) { return this.InternalGetAttachments( new Attachment[] { attachment }, bodyType, additionalProperties, - ServiceErrorHandling.ThrowOnError); + ServiceErrorHandling.ThrowOnError, + token); } /// @@ -1865,14 +1950,15 @@ internal Task> GetAttachment( /// Service response collection. internal Task> CreateAttachments( string parentItemId, - IEnumerable attachments) + IEnumerable attachments, + CancellationToken token) { CreateAttachmentRequest request = new CreateAttachmentRequest(this, ServiceErrorHandling.ReturnErrors); request.ParentItemId = parentItemId; request.Attachments.AddRange(attachments); - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -1880,13 +1966,13 @@ internal Task> CreateAttachm /// /// The attachments. /// Service response collection. - internal Task> DeleteAttachments(IEnumerable attachments) + internal Task> DeleteAttachments(IEnumerable attachments, CancellationToken token) { DeleteAttachmentRequest request = new DeleteAttachmentRequest(this, ServiceErrorHandling.ReturnErrors); request.Attachments.AddRange(attachments); - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } #endregion @@ -1945,7 +2031,8 @@ public async Task ResolveName( IEnumerable parentFolderIds, ResolveNameSearchLocation searchScope, bool returnContactDetails, - PropertySet contactDataPropertySet) + PropertySet contactDataPropertySet, + CancellationToken token = default(CancellationToken)) { if (contactDataPropertySet != null) { @@ -1966,7 +2053,7 @@ public async Task ResolveName( request.SearchLocation = searchScope; request.ContactDataPropertySet = contactDataPropertySet; - return (await request.ExecuteAsync().ConfigureAwait(false))[0].Resolutions; + return (await request.ExecuteAsync(token).ConfigureAwait(false))[0].Resolutions; } /// @@ -2017,7 +2104,7 @@ public Task ResolveName( /// /// The e-mail address of the group. /// An ExpandGroupResults containing the members of the group. - public async Task ExpandGroup(EmailAddress emailAddress) + public async Task ExpandGroup(EmailAddress emailAddress, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(emailAddress, "emailAddress"); @@ -2025,7 +2112,7 @@ public async Task ExpandGroup(EmailAddress emailAddress) request.EmailAddress = emailAddress; - return (await request.ExecuteAsync().ConfigureAwait(false))[0].Members; + return (await request.ExecuteAsync(token).ConfigureAwait(false))[0].Members; } /// @@ -2077,12 +2164,12 @@ public Task ExpandGroup(string address, string routingType) /// /// The e-mail address of the user. /// The password expiration date. - public async Task GetPasswordExpirationDate(string mailboxSmtpAddress) + public async Task GetPasswordExpirationDate(string mailboxSmtpAddress, CancellationToken token = default(CancellationToken)) { GetPasswordExpirationDateRequest request = new GetPasswordExpirationDateRequest(this); request.MailboxSmtpAddress = mailboxSmtpAddress; - return (await request.Execute().ConfigureAwait(false)).PasswordExpirationDate; + return (await request.Execute(token).ConfigureAwait(false)).PasswordExpirationDate; } #endregion @@ -2100,6 +2187,7 @@ public async Task SubscribeToPullNotifications( IEnumerable folderIds, int timeout, string watermark, + CancellationToken token = default(CancellationToken), params EventType[] eventTypes) { EwsUtilities.ValidateParamCollection(folderIds, "folderIds"); @@ -2108,7 +2196,7 @@ public async Task SubscribeToPullNotifications( folderIds, timeout, watermark, - eventTypes).ExecuteAsync().ConfigureAwait(false))[0].Subscription; + eventTypes).ExecuteAsync(token).ConfigureAwait(false))[0].Subscription; } /// @@ -2121,7 +2209,9 @@ public async Task SubscribeToPullNotifications( public async Task SubscribeToPullNotificationsOnAllFolders( int timeout, string watermark, - params EventType[] eventTypes) + CancellationToken token = default(CancellationToken), + params EventType[] eventTypes + ) { EwsUtilities.ValidateMethodVersion( this, @@ -2132,7 +2222,7 @@ public async Task SubscribeToPullNotificationsOnAllFolders( null, timeout, watermark, - eventTypes).ExecuteAsync().ConfigureAwait(false))[0].Subscription; + eventTypes).ExecuteAsync(token).ConfigureAwait(false))[0].Subscription; } /// @@ -2174,9 +2264,9 @@ private SubscribeToPullNotificationsRequest BuildSubscribeToPullNotificationsReq /// Unsubscribes from a subscription. Calling this method results in a call to EWS. /// /// The Id of the pull subscription to unsubscribe from. - internal System.Threading.Tasks.Task Unsubscribe(string subscriptionId) + internal System.Threading.Tasks.Task Unsubscribe(string subscriptionId, CancellationToken token) { - return this.BuildUnsubscribeRequest(subscriptionId).ExecuteAsync(); + return this.BuildUnsubscribeRequest(subscriptionId).ExecuteAsync(token); } /// @@ -2201,9 +2291,9 @@ private UnsubscribeRequest BuildUnsubscribeRequest(string subscriptionId) /// The Id of the pull subscription for which to get the events. /// The watermark representing the point in time where to start receiving events. /// A GetEventsResults containing a list of events associated with the subscription. - internal async Task GetEvents(string subscriptionId, string watermark) + internal async Task GetEvents(string subscriptionId, string watermark, CancellationToken token) { - return (await this.BuildGetEventsRequest(subscriptionId, watermark).ExecuteAsync().ConfigureAwait(false))[0].Results; + return (await this.BuildGetEventsRequest(subscriptionId, watermark).ExecuteAsync(token).ConfigureAwait(false))[0].Results; } /// @@ -2241,6 +2331,7 @@ public async Task SubscribeToPushNotifications( Uri url, int frequency, string watermark, + CancellationToken token = default(CancellationToken), params EventType[] eventTypes) { EwsUtilities.ValidateParamCollection(folderIds, "folderIds"); @@ -2252,7 +2343,7 @@ public async Task SubscribeToPushNotifications( watermark, null, null, // AnchorMailbox - eventTypes).ExecuteAsync().ConfigureAwait(false))[0].Subscription; + eventTypes).ExecuteAsync(token).ConfigureAwait(false))[0].Subscription; } /// @@ -2267,6 +2358,7 @@ public async Task SubscribeToPushNotificationsOnAllFolders( Uri url, int frequency, string watermark, + CancellationToken token = default(CancellationToken), params EventType[] eventTypes) { EwsUtilities.ValidateMethodVersion( @@ -2281,7 +2373,7 @@ public async Task SubscribeToPushNotificationsOnAllFolders( watermark, null, null, // AnchorMailbox - eventTypes).ExecuteAsync().ConfigureAwait(false))[0].Subscription; + eventTypes).ExecuteAsync(token).ConfigureAwait(false))[0].Subscription; } /// @@ -2300,6 +2392,7 @@ public async Task SubscribeToPushNotifications( int frequency, string watermark, string callerData, + CancellationToken token = default(CancellationToken), params EventType[] eventTypes) { EwsUtilities.ValidateParamCollection(folderIds, "folderIds"); @@ -2311,7 +2404,7 @@ public async Task SubscribeToPushNotifications( watermark, callerData, null, // AnchorMailbox - eventTypes).ExecuteAsync().ConfigureAwait(false))[0].Subscription; + eventTypes).ExecuteAsync(token).ConfigureAwait(false))[0].Subscription; } /// @@ -2330,6 +2423,7 @@ public async Task SubscribeToGroupPushNotifications( int frequency, string watermark, string callerData, + CancellationToken token = default(CancellationToken), params EventType[] eventTypes) { var folderIds = new FolderId[] { new FolderId(WellKnownFolderName.Inbox, new Mailbox(groupMailboxSmtp)) }; @@ -2340,7 +2434,7 @@ public async Task SubscribeToGroupPushNotifications( watermark, callerData, groupMailboxSmtp, // AnchorMailbox - eventTypes).ExecuteAsync().ConfigureAwait(false))[0].Subscription; + eventTypes).ExecuteAsync(token).ConfigureAwait(false))[0].Subscription; } /// @@ -2357,6 +2451,7 @@ public async Task SubscribeToPushNotificationsOnAllFolders( int frequency, string watermark, string callerData, + CancellationToken token = default(CancellationToken), params EventType[] eventTypes) { EwsUtilities.ValidateMethodVersion( @@ -2371,7 +2466,7 @@ public async Task SubscribeToPushNotificationsOnAllFolders( watermark, callerData, null, // AnchorMailbox - eventTypes).ExecuteAsync().ConfigureAwait(false))[0].Subscription; + eventTypes).ExecuteAsync(token).ConfigureAwait(false))[0].Subscription; } /// @@ -2380,7 +2475,8 @@ public async Task SubscribeToPushNotificationsOnAllFolders( /// TeamMailbox email address /// SharePoint site URL /// TeamMailbox lifecycle state - public System.Threading.Tasks.Task SetTeamMailbox(EmailAddress emailAddress, Uri sharePointSiteUrl, TeamMailboxLifecycleState state) + public System.Threading.Tasks.Task SetTeamMailbox(EmailAddress emailAddress, Uri sharePointSiteUrl, TeamMailboxLifecycleState state, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateMethodVersion(this, ExchangeVersion.Exchange2013, "SetTeamMailbox"); @@ -2395,14 +2491,14 @@ public System.Threading.Tasks.Task SetTeamMailbox(EmailAddress emailAddress, Uri } SetTeamMailboxRequest request = new SetTeamMailboxRequest(this, emailAddress, sharePointSiteUrl, state); - return request.Execute(); + return request.Execute(token); } /// /// Unpin a TeamMailbox /// /// TeamMailbox email address - public System.Threading.Tasks.Task UnpinTeamMailbox(EmailAddress emailAddress) + public System.Threading.Tasks.Task UnpinTeamMailbox(EmailAddress emailAddress, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateMethodVersion(this, ExchangeVersion.Exchange2013, "UnpinTeamMailbox"); @@ -2412,7 +2508,7 @@ public System.Threading.Tasks.Task UnpinTeamMailbox(EmailAddress emailAddress) } UnpinTeamMailboxRequest request = new UnpinTeamMailboxRequest(this, emailAddress); - return request.Execute(); + return request.Execute(token); } /// @@ -2469,6 +2565,7 @@ private SubscribeToPushNotificationsRequest BuildSubscribeToPushNotificationsReq /// A StreamingSubscription representing the new subscription. public async System.Threading.Tasks.Task SubscribeToStreamingNotifications( IEnumerable folderIds, + CancellationToken token = default(CancellationToken), params EventType[] eventTypes) { EwsUtilities.ValidateMethodVersion( @@ -2478,7 +2575,7 @@ public async System.Threading.Tasks.Task SubscribeToStrea EwsUtilities.ValidateParamCollection(folderIds, "folderIds"); - return (await this.BuildSubscribeToStreamingNotificationsRequest(folderIds, eventTypes).ExecuteAsync().ConfigureAwait(false))[0].Subscription; + return (await this.BuildSubscribeToStreamingNotificationsRequest(folderIds, eventTypes).ExecuteAsync(token).ConfigureAwait(false))[0].Subscription; } /// @@ -2487,6 +2584,7 @@ public async System.Threading.Tasks.Task SubscribeToStrea /// The event types to subscribe to. /// A StreamingSubscription representing the new subscription. public async Task SubscribeToStreamingNotificationsOnAllFolders( + CancellationToken token = default(CancellationToken), params EventType[] eventTypes) { EwsUtilities.ValidateMethodVersion( @@ -2494,7 +2592,7 @@ public async Task SubscribeToStreamingNotificationsOnAllF ExchangeVersion.Exchange2010_SP1, "SubscribeToStreamingNotificationsOnAllFolders"); - return (await this.BuildSubscribeToStreamingNotificationsRequest(null, eventTypes).ExecuteAsync().ConfigureAwait(false))[0].Subscription; + return (await this.BuildSubscribeToStreamingNotificationsRequest(null, eventTypes).ExecuteAsync(token).ConfigureAwait(false))[0].Subscription; } /// @@ -2571,7 +2669,8 @@ public async System.Threading.Tasks.Task> SyncFolde int maxChangesReturned, int numberOfDays, SyncFolderItemsScope syncScope, - string syncState) + string syncState, + CancellationToken token = default(CancellationToken)) { return (await this.BuildSyncFolderItemsRequest( syncFolderId, @@ -2580,7 +2679,7 @@ public async System.Threading.Tasks.Task> SyncFolde maxChangesReturned, numberOfDays, syncScope, - syncState).ExecuteAsync().ConfigureAwait(false))[0].Changes; + syncState).ExecuteAsync(token).ConfigureAwait(false))[0].Changes; } /// @@ -2632,12 +2731,13 @@ private SyncFolderItemsRequest BuildSyncFolderItemsRequest( public async Task> SyncFolderHierarchy( FolderId syncFolderId, PropertySet propertySet, - string syncState) + string syncState, + CancellationToken token = default(CancellationToken)) { return (await this.BuildSyncFolderHierarchyRequest( syncFolderId, propertySet, - syncState).ExecuteAsync().ConfigureAwait(false))[0].Changes; + syncState).ExecuteAsync(token).ConfigureAwait(false))[0].Changes; } /// @@ -2687,7 +2787,7 @@ private SyncFolderHierarchyRequest BuildSyncFolderHierarchyRequest( /// /// The SMTP address of the user for which to retrieve OOF settings. /// An OofSettings instance containing OOF information for the specified user. - public async Task GetUserOofSettings(string smtpAddress) + public async Task GetUserOofSettings(string smtpAddress, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(smtpAddress, "smtpAddress"); @@ -2695,7 +2795,7 @@ public async Task GetUserOofSettings(string smtpAddress) request.SmtpAddress = smtpAddress; - return (await request.Execute().ConfigureAwait(false)).OofSettings; + return (await request.Execute(token).ConfigureAwait(false)).OofSettings; } /// @@ -2703,7 +2803,7 @@ public async Task GetUserOofSettings(string smtpAddress) /// /// The SMTP address of the user for which to set OOF settings. /// The OOF settings. - public System.Threading.Tasks.Task SetUserOofSettings(string smtpAddress, OofSettings oofSettings) + public System.Threading.Tasks.Task SetUserOofSettings(string smtpAddress, OofSettings oofSettings, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(smtpAddress, "smtpAddress"); EwsUtilities.ValidateParam(oofSettings, "oofSettings"); @@ -2713,7 +2813,7 @@ public System.Threading.Tasks.Task SetUserOofSettings(string smtpAddress, OofSet request.SmtpAddress = smtpAddress; request.OofSettings = oofSettings; - return request.Execute(); + return request.Execute(token); } /// @@ -2732,7 +2832,8 @@ public Task GetUserAvailability( IEnumerable attendees, TimeWindow timeWindow, AvailabilityData requestedData, - AvailabilityOptions options) + AvailabilityOptions options, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParamCollection(attendees, "attendees"); EwsUtilities.ValidateParam(timeWindow, "timeWindow"); @@ -2745,7 +2846,7 @@ public Task GetUserAvailability( request.RequestedData = requestedData; request.Options = options; - return request.Execute(); + return request.Execute(token); } /// @@ -2775,11 +2876,11 @@ public Task GetUserAvailability( /// Retrieves a collection of all room lists in the organization. /// /// An EmailAddressCollection containing all the room lists in the organization. - public async Task GetRoomLists() + public async Task GetRoomLists(CancellationToken token = default(CancellationToken)) { GetRoomListsRequest request = new GetRoomListsRequest(this); - return (await request.Execute().ConfigureAwait(false)).RoomLists; + return (await request.Execute(token).ConfigureAwait(false)).RoomLists; } /// @@ -2787,7 +2888,7 @@ public async Task GetRoomLists() /// /// The e-mail address of the room list. /// A collection of EmailAddress objects representing all the rooms within the specifed room list. - public async Task> GetRooms(EmailAddress emailAddress) + public async Task> GetRooms(EmailAddress emailAddress, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(emailAddress, "emailAddress"); @@ -2795,7 +2896,7 @@ public async Task> GetRooms(EmailAddress emailAddress) request.RoomList = emailAddress; - return (await request.Execute().ConfigureAwait(false)).Rooms; + return (await request.Execute(token).ConfigureAwait(false)).Rooms; } #endregion @@ -2806,7 +2907,7 @@ public async Task> GetRooms(EmailAddress emailAddress) /// The view controlling the number of conversations returned. /// The Id of the folder in which to search for conversations. /// Collection of conversations. - public async Task> FindConversation(ViewBase view, FolderId folderId) + public async Task> FindConversation(ViewBase view, FolderId folderId, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(view, "view"); EwsUtilities.ValidateParam(folderId, "folderId"); @@ -2820,7 +2921,7 @@ public async Task> FindConversation(ViewBase view, Fol request.View = view; request.FolderId = new FolderIdWrapper(folderId); - return (await request.Execute().ConfigureAwait(false)).Conversations; + return (await request.Execute(token).ConfigureAwait(false)).Conversations; } /// @@ -2837,7 +2938,8 @@ public async Task> FindConversation(ViewBase view, Fol public async Task> FindGroupConversation( ViewBase view, FolderId folderId, - string anchorMailbox) + string anchorMailbox, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(view, "view"); EwsUtilities.ValidateParam(folderId, "folderId"); @@ -2853,7 +2955,7 @@ public async Task> FindGroupConversation( request.FolderId = new FolderIdWrapper(folderId); request.AnchorMailbox = anchorMailbox; - return (await request.Execute().ConfigureAwait(false)).Conversations; + return (await request.Execute(token).ConfigureAwait(false)).Conversations; } /// @@ -2863,7 +2965,7 @@ public async Task> FindGroupConversation( /// The Id of the folder in which to search for conversations. /// The query string for which the search is being performed /// Collection of conversations. - public async Task> FindConversation(ViewBase view, FolderId folderId, string queryString) + public async Task> FindConversation(ViewBase view, FolderId folderId, string queryString, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(view, "view"); EwsUtilities.ValidateParamAllowNull(queryString, "queryString"); @@ -2879,7 +2981,7 @@ public async Task> FindConversation(ViewBase view, Fol request.FolderId = new FolderIdWrapper(folderId); request.QueryString = queryString; - return (await request.Execute().ConfigureAwait(false)).Conversations; + return (await request.Execute(token).ConfigureAwait(false)).Conversations; } /// @@ -2891,7 +2993,7 @@ public async Task> FindConversation(ViewBase view, Fol /// The query string for which the search is being performed /// Flag indicating if highlight terms should be returned in the response /// FindConversation results. - public async Task FindConversation(ViewBase view, FolderId folderId, string queryString, bool returnHighlightTerms) + public async Task FindConversation(ViewBase view, FolderId folderId, string queryString, bool returnHighlightTerms, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(view, "view"); EwsUtilities.ValidateParamAllowNull(queryString, "queryString"); @@ -2909,7 +3011,7 @@ public async Task FindConversation(ViewBase view, Folde request.QueryString = queryString; request.ReturnHighlightTerms = returnHighlightTerms; - return (await request.Execute().ConfigureAwait(false)).Results; + return (await request.Execute(token).ConfigureAwait(false)).Results; } /// @@ -2922,7 +3024,7 @@ public async Task FindConversation(ViewBase view, Folde /// Flag indicating if highlight terms should be returned in the response /// The mailbox scope to reference. /// FindConversation results. - public async Task FindConversation(ViewBase view, FolderId folderId, string queryString, bool returnHighlightTerms, MailboxSearchLocation? mailboxScope) + public async Task FindConversation(ViewBase view, FolderId folderId, string queryString, bool returnHighlightTerms, MailboxSearchLocation? mailboxScope, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(view, "view"); EwsUtilities.ValidateParamAllowNull(queryString, "queryString"); @@ -2942,7 +3044,7 @@ public async Task FindConversation(ViewBase view, Folde request.ReturnHighlightTerms = returnHighlightTerms; request.MailboxScope = mailboxScope; - return (await request.Execute().ConfigureAwait(false)).Results; + return (await request.Execute(token).ConfigureAwait(false)).Results; } /// @@ -2965,7 +3067,8 @@ internal Task> InternalG MailboxSearchLocation? mailboxScope, int? maxItemsToReturn, string anchorMailbox, - ServiceErrorHandling errorHandling) + ServiceErrorHandling errorHandling, + CancellationToken token) { EwsUtilities.ValidateParam(conversations, "conversations"); EwsUtilities.ValidateParam(propertySet, "itemProperties"); @@ -2984,7 +3087,7 @@ internal Task> InternalG request.AnchorMailbox = anchorMailbox; request.Conversations = conversations.ToList(); - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -2999,7 +3102,8 @@ public Task> GetConversa IEnumerable conversations, PropertySet propertySet, IEnumerable foldersToIgnore, - ConversationSortOrder? sortOrder) + ConversationSortOrder? sortOrder, + CancellationToken token = default(CancellationToken)) { return this.InternalGetConversationItems( conversations, @@ -3009,7 +3113,8 @@ public Task> GetConversa null, /* mailboxScope */ null, /* maxItemsToReturn*/ null, /* anchorMailbox */ - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -3026,7 +3131,8 @@ public async Task GetConversationItems( PropertySet propertySet, string syncState, IEnumerable foldersToIgnore, - ConversationSortOrder? sortOrder) + ConversationSortOrder? sortOrder, + CancellationToken token = default(CancellationToken)) { List conversations = new List(); conversations.Add(new ConversationRequest(conversationId, syncState)); @@ -3039,7 +3145,8 @@ public async Task GetConversationItems( null, /* mailboxScope */ null, /* maxItemsToReturn */ null, /* anchorMailbox */ - ServiceErrorHandling.ThrowOnError).ConfigureAwait(false))[0].Conversation; + ServiceErrorHandling.ThrowOnError, + token).ConfigureAwait(false))[0].Conversation; } /// @@ -3062,7 +3169,8 @@ public async Task GetGroupConversationItems( string syncState, IEnumerable foldersToIgnore, ConversationSortOrder? sortOrder, - string anchorMailbox) + string anchorMailbox, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(anchorMailbox, "anchorMailbox"); @@ -3077,7 +3185,8 @@ public async Task GetGroupConversationItems( null, /* mailboxScope */ null, /* maxItemsToReturn */ anchorMailbox, /* anchorMailbox */ - ServiceErrorHandling.ThrowOnError).ConfigureAwait(false))[0].Conversation; + ServiceErrorHandling.ThrowOnError, + token).ConfigureAwait(false))[0].Conversation; } /// @@ -3094,7 +3203,8 @@ public Task> GetConversa PropertySet propertySet, IEnumerable foldersToIgnore, ConversationSortOrder? sortOrder, - MailboxSearchLocation? mailboxScope) + MailboxSearchLocation? mailboxScope, + CancellationToken token = default(CancellationToken)) { return this.InternalGetConversationItems( conversations, @@ -3104,7 +3214,8 @@ public Task> GetConversa mailboxScope, null, /* maxItemsToReturn*/ null, /* anchorMailbox */ - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -3130,7 +3241,8 @@ private Task> ApplyConversationAction StringList categories, bool enableAlwaysDelete, FolderId destinationFolderId, - ServiceErrorHandling errorHandlingMode) + ServiceErrorHandling errorHandlingMode, + CancellationToken token) { EwsUtilities.Assert( actionType == ConversationActionType.AlwaysCategorize || @@ -3161,7 +3273,7 @@ private Task> ApplyConversationAction request.ConversationActions.Add(action); } - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -3191,7 +3303,8 @@ private Task> ApplyConversationOneTim Guid? retentionPolicyTagId, Flag flag, bool? suppressReadReceipts, - ServiceErrorHandling errorHandlingMode) + ServiceErrorHandling errorHandlingMode, + CancellationToken token) { EwsUtilities.Assert( actionType == ConversationActionType.Move || @@ -3230,7 +3343,7 @@ private Task> ApplyConversationOneTim request.ConversationActions.Add(action); } - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -3245,7 +3358,8 @@ private Task> ApplyConversationOneTim public Task> EnableAlwaysCategorizeItemsInConversations( IEnumerable conversationId, IEnumerable categories, - bool processSynchronously) + bool processSynchronously, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParamCollection(categories, "categories"); return this.ApplyConversationAction( @@ -3255,7 +3369,8 @@ public Task> EnableAlwaysCategorizeIt new StringList(categories), false, null, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -3268,7 +3383,8 @@ public Task> EnableAlwaysCategorizeIt /// public Task> DisableAlwaysCategorizeItemsInConversations( IEnumerable conversationId, - bool processSynchronously) + bool processSynchronously, + CancellationToken token = default(CancellationToken)) { return this.ApplyConversationAction( ConversationActionType.AlwaysCategorize, @@ -3277,7 +3393,8 @@ public Task> DisableAlwaysCategorizeI null, false, null, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -3290,7 +3407,8 @@ public Task> DisableAlwaysCategorizeI /// public Task> EnableAlwaysDeleteItemsInConversations( IEnumerable conversationId, - bool processSynchronously) + bool processSynchronously, + CancellationToken token = default(CancellationToken)) { return this.ApplyConversationAction( ConversationActionType.AlwaysDelete, @@ -3299,7 +3417,8 @@ public Task> EnableAlwaysDeleteItemsI null, true, null, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -3312,7 +3431,8 @@ public Task> EnableAlwaysDeleteItemsI /// public Task> DisableAlwaysDeleteItemsInConversations( IEnumerable conversationId, - bool processSynchronously) + bool processSynchronously, + CancellationToken token = default(CancellationToken)) { return this.ApplyConversationAction( ConversationActionType.AlwaysDelete, @@ -3321,7 +3441,8 @@ public Task> DisableAlwaysDeleteItems null, false, null, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -3336,7 +3457,8 @@ public Task> DisableAlwaysDeleteItems public Task> EnableAlwaysMoveItemsInConversations( IEnumerable conversationId, FolderId destinationFolderId, - bool processSynchronously) + bool processSynchronously, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId"); return this.ApplyConversationAction( @@ -3346,7 +3468,8 @@ public Task> EnableAlwaysMoveItemsInC null, false, destinationFolderId, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -3359,7 +3482,8 @@ public Task> EnableAlwaysMoveItemsInC /// public Task> DisableAlwaysMoveItemsInConversations( IEnumerable conversationIds, - bool processSynchronously) + bool processSynchronously, + CancellationToken token = default(CancellationToken)) { return this.ApplyConversationAction( ConversationActionType.AlwaysMove, @@ -3368,7 +3492,8 @@ public Task> DisableAlwaysMoveItemsIn null, false, null, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -3384,7 +3509,8 @@ public Task> DisableAlwaysMoveItemsIn public Task> MoveItemsInConversations( IEnumerable> idLastSyncTimePairs, FolderId contextFolderId, - FolderId destinationFolderId) + FolderId destinationFolderId, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId"); return this.ApplyConversationOneTimeAction( @@ -3398,7 +3524,8 @@ public Task> MoveItemsInConversations null, null, null, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -3414,7 +3541,8 @@ public Task> MoveItemsInConversations public Task> CopyItemsInConversations( IEnumerable> idLastSyncTimePairs, FolderId contextFolderId, - FolderId destinationFolderId) + FolderId destinationFolderId, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId"); return this.ApplyConversationOneTimeAction( @@ -3428,7 +3556,8 @@ public Task> CopyItemsInConversations null, null, null, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -3443,7 +3572,8 @@ public Task> CopyItemsInConversations public Task> DeleteItemsInConversations( IEnumerable> idLastSyncTimePairs, FolderId contextFolderId, - DeleteMode deleteMode) + DeleteMode deleteMode, + CancellationToken token = default(CancellationToken)) { return this.ApplyConversationOneTimeAction( ConversationActionType.Delete, @@ -3456,7 +3586,8 @@ public Task> DeleteItemsInConversatio null, null, null, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -3472,7 +3603,8 @@ public Task> DeleteItemsInConversatio public Task> SetReadStateForItemsInConversations( IEnumerable> idLastSyncTimePairs, FolderId contextFolderId, - bool isRead) + bool isRead, + CancellationToken token = default(CancellationToken)) { return this.ApplyConversationOneTimeAction( ConversationActionType.SetReadState, @@ -3485,7 +3617,8 @@ public Task> SetReadStateForItemsInCo null, null, null, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -3503,7 +3636,8 @@ public Task> SetReadStateForItemsInCo IEnumerable> idLastSyncTimePairs, FolderId contextFolderId, bool isRead, - bool suppressReadReceipts) + bool suppressReadReceipts, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateMethodVersion(this, ExchangeVersion.Exchange2013, "SetReadStateForItemsInConversations"); @@ -3518,7 +3652,8 @@ public Task> SetReadStateForItemsInCo null, null, suppressReadReceipts, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -3536,7 +3671,8 @@ public Task> SetRetentionPolicyForIte IEnumerable> idLastSyncTimePairs, FolderId contextFolderId, RetentionType retentionPolicyType, - Guid? retentionPolicyTagId) + Guid? retentionPolicyTagId, + CancellationToken token = default(CancellationToken)) { return this.ApplyConversationOneTimeAction( ConversationActionType.SetRetentionPolicy, @@ -3549,7 +3685,8 @@ public Task> SetRetentionPolicyForIte retentionPolicyTagId, null, null, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -3564,7 +3701,8 @@ public Task> SetRetentionPolicyForIte public Task> SetFlagStatusForItemsInConversations( IEnumerable> idLastSyncTimePairs, FolderId contextFolderId, - Flag flagStatus) + Flag flagStatus, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateMethodVersion(this, ExchangeVersion.Exchange2013, "SetFlagStatusForItemsInConversations"); @@ -3579,7 +3717,8 @@ public Task> SetFlagStatusForItemsInC null, flagStatus, null, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } #endregion @@ -3596,7 +3735,8 @@ public Task> SetFlagStatusForItemsInC private Task> InternalConvertIds( IEnumerable ids, IdFormat destinationFormat, - ServiceErrorHandling errorHandling) + ServiceErrorHandling errorHandling, + CancellationToken token) { EwsUtilities.ValidateParamCollection(ids, "ids"); @@ -3605,7 +3745,7 @@ private Task> InternalConvertIds( request.Ids.AddRange(ids); request.DestinationFormat = destinationFormat; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -3614,14 +3754,15 @@ private Task> InternalConvertIds( /// The Ids to convert. /// The destination format. /// A ServiceResponseCollection providing conversion results for each specified Ids. - public Task> ConvertIds(IEnumerable ids, IdFormat destinationFormat) + public Task> ConvertIds(IEnumerable ids, IdFormat destinationFormat, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParamCollection(ids, "ids"); return this.InternalConvertIds( ids, destinationFormat, - ServiceErrorHandling.ReturnErrors); + ServiceErrorHandling.ReturnErrors, + token); } /// @@ -3630,14 +3771,15 @@ public Task> ConvertIds(IEnumerable /// The Id to convert. /// The destination format. /// The converted Id. - public async Task ConvertId(AlternateIdBase id, IdFormat destinationFormat) + public async Task ConvertId(AlternateIdBase id, IdFormat destinationFormat, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(id, "id"); ServiceResponseCollection responses = await this.InternalConvertIds( new AlternateIdBase[] { id }, destinationFormat, - ServiceErrorHandling.ThrowOnError); + ServiceErrorHandling.ThrowOnError, + token); return responses[0].ConvertedId; } @@ -3674,7 +3816,8 @@ public Task> AddDelegates( public async Task> AddDelegates( Mailbox mailbox, MeetingRequestsDeliveryScope? meetingRequestsDeliveryScope, - IEnumerable delegateUsers) + IEnumerable delegateUsers, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(mailbox, "mailbox"); EwsUtilities.ValidateParamCollection(delegateUsers, "delegateUsers"); @@ -3685,7 +3828,7 @@ public async Task> AddDelegates( request.DelegateUsers.AddRange(delegateUsers); request.MeetingRequestsDeliveryScope = meetingRequestsDeliveryScope; - DelegateManagementResponse response = await request.Execute().ConfigureAwait(false); + DelegateManagementResponse response = await request.Execute(token).ConfigureAwait(false); return response.DelegateUserResponses; } @@ -3699,6 +3842,7 @@ public async Task> AddDelegates( public Task> UpdateDelegates( Mailbox mailbox, MeetingRequestsDeliveryScope? meetingRequestsDeliveryScope, + CancellationToken token = default(CancellationToken), params DelegateUser[] delegateUsers) { return this.UpdateDelegates( @@ -3717,7 +3861,8 @@ public Task> UpdateDelegates( public async Task> UpdateDelegates( Mailbox mailbox, MeetingRequestsDeliveryScope? meetingRequestsDeliveryScope, - IEnumerable delegateUsers) + IEnumerable delegateUsers, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(mailbox, "mailbox"); EwsUtilities.ValidateParamCollection(delegateUsers, "delegateUsers"); @@ -3728,7 +3873,7 @@ public async Task> UpdateDelegates( request.DelegateUsers.AddRange(delegateUsers); request.MeetingRequestsDeliveryScope = meetingRequestsDeliveryScope; - DelegateManagementResponse response = await request.Execute().ConfigureAwait(false); + DelegateManagementResponse response = await request.Execute(token).ConfigureAwait(false); return response.DelegateUserResponses; } @@ -3738,9 +3883,9 @@ public async Task> UpdateDelegates( /// The mailbox to remove delegates from. /// The Ids of the delegate users to remove. /// A collection of DelegateUserResponse objects providing the results of the operation. - public Task> RemoveDelegates(Mailbox mailbox, params UserId[] userIds) + public Task> RemoveDelegates(Mailbox mailbox, CancellationToken token = default(CancellationToken), params UserId[] userIds) { - return this.RemoveDelegates(mailbox, (IEnumerable)userIds); + return this.RemoveDelegates(mailbox, (IEnumerable)userIds, token); } /// @@ -3749,7 +3894,7 @@ public Task> RemoveDelegates(Mailbox mailbox, p /// The mailbox to remove delegates from. /// The Ids of the delegate users to remove. /// A collection of DelegateUserResponse objects providing the results of the operation. - public async Task> RemoveDelegates(Mailbox mailbox, IEnumerable userIds) + public async Task> RemoveDelegates(Mailbox mailbox, IEnumerable userIds, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(mailbox, "mailbox"); EwsUtilities.ValidateParamCollection(userIds, "userIds"); @@ -3759,7 +3904,7 @@ public async Task> RemoveDelegates(Mailbox mail request.Mailbox = mailbox; request.UserIds.AddRange(userIds); - DelegateManagementResponse response = await request.Execute().ConfigureAwait(false); + DelegateManagementResponse response = await request.Execute(token).ConfigureAwait(false); return response.DelegateUserResponses; } @@ -3773,6 +3918,7 @@ public async Task> RemoveDelegates(Mailbox mail public Task GetDelegates( Mailbox mailbox, bool includePermissions, + CancellationToken token = default(CancellationToken), params UserId[] userIds) { return this.GetDelegates( @@ -3791,7 +3937,8 @@ public Task GetDelegates( public async Task GetDelegates( Mailbox mailbox, bool includePermissions, - IEnumerable userIds) + IEnumerable userIds, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(mailbox, "mailbox"); @@ -3801,7 +3948,7 @@ public async Task GetDelegates( request.UserIds.AddRange(userIds); request.IncludePermissions = includePermissions; - GetDelegateResponse response = await request.Execute().ConfigureAwait(false); + GetDelegateResponse response = await request.Execute(token).ConfigureAwait(false); DelegateInformation delegateInformation = new DelegateInformation( response.DelegateUserResponses, response.MeetingRequestsDeliveryScope); @@ -3817,7 +3964,7 @@ public async Task GetDelegates( /// Creates a UserConfiguration. /// /// The UserConfiguration. - internal System.Threading.Tasks.Task CreateUserConfiguration(UserConfiguration userConfiguration) + internal System.Threading.Tasks.Task CreateUserConfiguration(UserConfiguration userConfiguration, CancellationToken token) { EwsUtilities.ValidateParam(userConfiguration, "userConfiguration"); @@ -3825,7 +3972,7 @@ internal System.Threading.Tasks.Task CreateUserConfiguration(UserConfiguration u request.UserConfiguration = userConfiguration; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -3833,7 +3980,7 @@ internal System.Threading.Tasks.Task CreateUserConfiguration(UserConfiguration u /// /// Name of the UserConfiguration to retrieve. /// Id of the folder containing the UserConfiguration. - internal System.Threading.Tasks.Task DeleteUserConfiguration(string name, FolderId parentFolderId) + internal System.Threading.Tasks.Task DeleteUserConfiguration(string name, FolderId parentFolderId, CancellationToken token) { EwsUtilities.ValidateParam(name, "name"); EwsUtilities.ValidateParam(parentFolderId, "parentFolderId"); @@ -3843,7 +3990,7 @@ internal System.Threading.Tasks.Task DeleteUserConfiguration(string name, Folder request.Name = name; request.ParentFolderId = parentFolderId; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -3856,7 +4003,8 @@ internal System.Threading.Tasks.Task DeleteUserConfiguration(string name, Folder internal async Task GetUserConfiguration( string name, FolderId parentFolderId, - UserConfigurationProperties properties) + UserConfigurationProperties properties, + CancellationToken token) { EwsUtilities.ValidateParam(name, "name"); EwsUtilities.ValidateParam(parentFolderId, "parentFolderId"); @@ -3867,7 +4015,7 @@ internal async Task GetUserConfiguration( request.ParentFolderId = parentFolderId; request.Properties = properties; - return (await request.ExecuteAsync().ConfigureAwait(false))[0].UserConfiguration; + return (await request.ExecuteAsync(token).ConfigureAwait(false))[0].UserConfiguration; } /// @@ -3875,7 +4023,8 @@ internal async Task GetUserConfiguration( /// /// The userConfiguration containing properties to load. /// Properties to retrieve. - internal System.Threading.Tasks.Task LoadPropertiesForUserConfiguration(UserConfiguration userConfiguration, UserConfigurationProperties properties) + internal System.Threading.Tasks.Task LoadPropertiesForUserConfiguration(UserConfiguration userConfiguration, UserConfigurationProperties properties, + CancellationToken token) { EwsUtilities.Assert( userConfiguration != null, @@ -3887,14 +4036,14 @@ internal System.Threading.Tasks.Task LoadPropertiesForUserConfiguration(UserConf request.UserConfiguration = userConfiguration; request.Properties = properties; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// /// Updates a UserConfiguration. /// /// The UserConfiguration. - internal System.Threading.Tasks.Task UpdateUserConfiguration(UserConfiguration userConfiguration) + internal System.Threading.Tasks.Task UpdateUserConfiguration(UserConfiguration userConfiguration, CancellationToken token) { EwsUtilities.ValidateParam(userConfiguration, "userConfiguration"); @@ -3902,7 +4051,7 @@ internal System.Threading.Tasks.Task UpdateUserConfiguration(UserConfiguration u request.UserConfiguration = userConfiguration; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } #endregion @@ -3912,11 +4061,11 @@ internal System.Threading.Tasks.Task UpdateUserConfiguration(UserConfiguration u /// Retrieves inbox rules of the authenticated user. /// /// A RuleCollection object containing the authenticated user's inbox rules. - public async Task GetInboxRules() + public async Task GetInboxRules(CancellationToken token = default(CancellationToken)) { GetInboxRulesRequest request = new GetInboxRulesRequest(this); - return (await request.Execute().ConfigureAwait(false)).Rules; + return (await request.Execute(token).ConfigureAwait(false)).Rules; } /// @@ -3924,14 +4073,14 @@ public async Task GetInboxRules() /// /// The SMTP address of the user whose inbox rules should be retrieved. /// A RuleCollection object containing the inbox rules of the specified user. - public async Task GetInboxRules(string mailboxSmtpAddress) + public async Task GetInboxRules(string mailboxSmtpAddress, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(mailboxSmtpAddress, "MailboxSmtpAddress"); GetInboxRulesRequest request = new GetInboxRulesRequest(this); request.MailboxSmtpAddress = mailboxSmtpAddress; - return (await request.Execute().ConfigureAwait(false)).Rules; + return (await request.Execute(token).ConfigureAwait(false)).Rules; } /// @@ -3941,12 +4090,13 @@ public async Task GetInboxRules(string mailboxSmtpAddress) /// Indicate whether or not to remove Outlook Rule Blob. public System.Threading.Tasks.Task UpdateInboxRules( IEnumerable operations, - bool removeOutlookRuleBlob) + bool removeOutlookRuleBlob, + CancellationToken token = default(CancellationToken)) { UpdateInboxRulesRequest request = new UpdateInboxRulesRequest(this); request.InboxRuleOperations = operations; request.RemoveOutlookRuleBlob = removeOutlookRuleBlob; - return request.Execute(); + return request.Execute(token); } /// @@ -3958,13 +4108,14 @@ public System.Threading.Tasks.Task UpdateInboxRules( public System.Threading.Tasks.Task UpdateInboxRules( IEnumerable operations, bool removeOutlookRuleBlob, - string mailboxSmtpAddress) + string mailboxSmtpAddress, + CancellationToken token = default(CancellationToken)) { UpdateInboxRulesRequest request = new UpdateInboxRulesRequest(this); request.InboxRuleOperations = operations; request.RemoveOutlookRuleBlob = removeOutlookRuleBlob; request.MailboxSmtpAddress = mailboxSmtpAddress; - return request.Execute(); + return request.Execute(token); } #endregion @@ -3977,14 +4128,14 @@ public System.Threading.Tasks.Task UpdateInboxRules( /// True if want to expand group membership /// True if only want the inplacehold configuration /// Service response object - public Task GetDiscoverySearchConfiguration(string searchId, bool expandGroupMembership, bool inPlaceHoldConfigurationOnly) + public Task GetDiscoverySearchConfiguration(string searchId, bool expandGroupMembership, bool inPlaceHoldConfigurationOnly, CancellationToken token = default(CancellationToken)) { GetDiscoverySearchConfigurationRequest request = new GetDiscoverySearchConfigurationRequest(this); request.SearchId = searchId; request.ExpandGroupMembership = expandGroupMembership; request.InPlaceHoldConfigurationOnly = inPlaceHoldConfigurationOnly; - return request.Execute(); + return request.Execute(token); } /// @@ -3993,13 +4144,13 @@ public Task GetDiscoverySearchConfigura /// Search filter /// True if want to expand group membership /// Service response object - public Task GetSearchableMailboxes(string searchFilter, bool expandGroupMembership) + public Task GetSearchableMailboxes(string searchFilter, bool expandGroupMembership, CancellationToken token = default(CancellationToken)) { GetSearchableMailboxesRequest request = new GetSearchableMailboxesRequest(this); request.SearchFilter = searchFilter; request.ExpandGroupMembership = expandGroupMembership; - return request.Execute(); + return request.Execute(token); } /// @@ -4008,7 +4159,7 @@ public Task GetSearchableMailboxes(string search /// Collection of query and mailboxes /// Search result type /// Collection of search mailboxes response object - public Task> SearchMailboxes(IEnumerable mailboxQueries, SearchResultType resultType) + public Task> SearchMailboxes(IEnumerable mailboxQueries, SearchResultType resultType, CancellationToken token = default(CancellationToken)) { SearchMailboxesRequest request = new SearchMailboxesRequest(this, ServiceErrorHandling.ReturnErrors); if (mailboxQueries != null) @@ -4018,7 +4169,7 @@ public Task> SearchMailboxes( request.ResultType = resultType; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -4039,7 +4190,8 @@ public Task> SearchMailboxes( SortDirection sortOrder, int pageSize, SearchPageDirection pageDirection, - string pageItemReference) + string pageItemReference, + CancellationToken token = default(CancellationToken)) { SearchMailboxesRequest request = new SearchMailboxesRequest(this, ServiceErrorHandling.ReturnErrors); if (mailboxQueries != null) @@ -4054,7 +4206,7 @@ public Task> SearchMailboxes( request.PageDirection = pageDirection; request.PageItemReference = pageItemReference; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -4062,13 +4214,13 @@ public Task> SearchMailboxes( /// /// Search mailboxes parameters /// Collection of search mailboxes response object - public Task> SearchMailboxes(SearchMailboxesParameters searchParameters) + public Task> SearchMailboxes(SearchMailboxesParameters searchParameters, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(searchParameters, "searchParameters"); EwsUtilities.ValidateParam(searchParameters.SearchQueries, "searchParameters.SearchQueries"); SearchMailboxesRequest request = this.CreateSearchMailboxesRequest(searchParameters); - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } /// @@ -4079,7 +4231,7 @@ public Task> SearchMailboxes( /// Query string /// Collection of mailboxes /// Service response object - public Task SetHoldOnMailboxes(string holdId, HoldAction actionType, string query, string[] mailboxes) + public Task SetHoldOnMailboxes(string holdId, HoldAction actionType, string query, string[] mailboxes, CancellationToken token = default(CancellationToken)) { SetHoldOnMailboxesRequest request = new SetHoldOnMailboxesRequest(this); request.HoldId = holdId; @@ -4088,7 +4240,7 @@ public Task SetHoldOnMailboxes(string holdId, HoldAc request.Mailboxes = mailboxes; request.InPlaceHoldIdentity = null; - return request.Execute(); + return request.Execute(token); } /// @@ -4113,7 +4265,7 @@ public Task SetHoldOnMailboxes(string holdId, HoldAc /// in-place hold identity /// item hold period /// Service response object - public Task SetHoldOnMailboxes(string holdId, HoldAction actionType, string query, string inPlaceHoldIdentity, string itemHoldPeriod) + public Task SetHoldOnMailboxes(string holdId, HoldAction actionType, string query, string inPlaceHoldIdentity, string itemHoldPeriod, CancellationToken token = default(CancellationToken)) { SetHoldOnMailboxesRequest request = new SetHoldOnMailboxesRequest(this); request.HoldId = holdId; @@ -4123,7 +4275,7 @@ public Task SetHoldOnMailboxes(string holdId, HoldAc request.InPlaceHoldIdentity = inPlaceHoldIdentity; request.ItemHoldPeriod = itemHoldPeriod; - return request.Execute(); + return request.Execute(token); } /// @@ -4131,7 +4283,7 @@ public Task SetHoldOnMailboxes(string holdId, HoldAc /// /// Set hold parameters /// Service response object - public Task SetHoldOnMailboxes(SetHoldOnMailboxesParameters parameters) + public Task SetHoldOnMailboxes(SetHoldOnMailboxesParameters parameters, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(parameters, "parameters"); @@ -4143,7 +4295,7 @@ public Task SetHoldOnMailboxes(SetHoldOnMailboxesPar request.Language = parameters.Language; request.InPlaceHoldIdentity = parameters.InPlaceHoldIdentity; - return request.Execute(); + return request.Execute(token); } /// @@ -4151,12 +4303,12 @@ public Task SetHoldOnMailboxes(SetHoldOnMailboxesPar /// /// Hold id /// Service response object - public Task GetHoldOnMailboxes(string holdId) + public Task GetHoldOnMailboxes(string holdId, CancellationToken token = default(CancellationToken)) { GetHoldOnMailboxesRequest request = new GetHoldOnMailboxesRequest(this); request.HoldId = holdId; - return request.Execute(); + return request.Execute(token); } /// @@ -4196,11 +4348,11 @@ public Task GetNonIndexableItemDetails(strin /// /// Get non indexable item details parameters /// Service response object - public Task GetNonIndexableItemDetails(GetNonIndexableItemDetailsParameters parameters) + public Task GetNonIndexableItemDetails(GetNonIndexableItemDetailsParameters parameters, CancellationToken token = default(CancellationToken)) { GetNonIndexableItemDetailsRequest request = this.CreateGetNonIndexableItemDetailsRequest(parameters); - return request.Execute(); + return request.Execute(token); } /// @@ -4224,11 +4376,11 @@ public Task GetNonIndexableItemStatistics /// /// Get non indexable item statistics parameters /// Service response object - public Task GetNonIndexableItemStatistics(GetNonIndexableItemStatisticsParameters parameters) + public Task GetNonIndexableItemStatistics(GetNonIndexableItemStatisticsParameters parameters, CancellationToken token = default(CancellationToken)) { GetNonIndexableItemStatisticsRequest request = this.CreateGetNonIndexableItemStatisticsRequest(parameters); - return request.Execute(); + return request.Execute(token); } /// @@ -4297,11 +4449,11 @@ private SearchMailboxesRequest CreateSearchMailboxesRequest(SearchMailboxesParam /// Get user retention policy tags. /// /// Service response object. - public Task GetUserRetentionPolicyTags() + public Task GetUserRetentionPolicyTags(CancellationToken token = default(CancellationToken)) { GetUserRetentionPolicyTagsRequest request = new GetUserRetentionPolicyTagsRequest(this); - return request.Execute(); + return request.Execute(token); } #endregion @@ -4498,11 +4650,11 @@ public Task> GetClientAc /// /// Token requests array /// A ServiceResponseCollection providing token results for each of the specified id and types. - public Task> GetClientAccessToken(ClientAccessTokenRequest[] tokenRequests) + public Task> GetClientAccessToken(ClientAccessTokenRequest[] tokenRequests, CancellationToken token = default(CancellationToken)) { GetClientAccessTokenRequest request = new GetClientAccessTokenRequest(this, ServiceErrorHandling.ReturnErrors); request.TokenRequests = tokenRequests; - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } #endregion @@ -4513,10 +4665,10 @@ public Task> GetClientAc /// Get the app manifests. /// /// Collection of manifests - public async Task> GetAppManifests() + public async Task> GetAppManifests(CancellationToken token = default(CancellationToken)) { GetAppManifestsRequest request = new GetAppManifestsRequest(this); - return (await request.Execute().ConfigureAwait(false)).Manifests; + return (await request.Execute(token).ConfigureAwait(false)).Manifests; } /// @@ -4525,13 +4677,13 @@ public async Task> GetAppManifests() /// The api version supported by the client. /// The schema version supported by the client. /// Collection of manifests - public async Task> GetAppManifests(string apiVersionSupported, string schemaVersionSupported) + public async Task> GetAppManifests(string apiVersionSupported, string schemaVersionSupported, CancellationToken token = default(CancellationToken)) { GetAppManifestsRequest request = new GetAppManifestsRequest(this); request.ApiVersionSupported = apiVersionSupported; request.SchemaVersionSupported = schemaVersionSupported; - return (await request.Execute().ConfigureAwait(false)).Apps; + return (await request.Execute(token).ConfigureAwait(false)).Apps; } /// @@ -4545,11 +4697,11 @@ public async Task> GetAppManifests(string apiVersionSuppor /// When this function succeeds, manifestStream is closed. This is by EWS design to /// release resource in timely manner. /// Exception will be thrown for errors. - public System.Threading.Tasks.Task InstallApp(Stream manifestStream) + public System.Threading.Tasks.Task InstallApp(Stream manifestStream, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(manifestStream, "manifestStream"); - return this.InternalInstallApp(manifestStream, marketplaceAssetId: null, marketplaceContentMarket: null, sendWelcomeEmail: false); + return this.InternalInstallApp(manifestStream, null, null, false, token); } /// @@ -4567,13 +4719,13 @@ public System.Threading.Tasks.Task InstallApp(Stream manifestStream) /// Whether to send welcome email for the addin /// True if the app was not already installed. False if it was not installed. Null if it is not a user mailbox. /// Exception will be thrown for errors. - internal async Task InternalInstallApp(Stream manifestStream, string marketplaceAssetId, string marketplaceContentMarket, bool sendWelcomeEmail) + internal async Task InternalInstallApp(Stream manifestStream, string marketplaceAssetId, string marketplaceContentMarket, bool sendWelcomeEmail, CancellationToken token) { EwsUtilities.ValidateParam(manifestStream, "manifestStream"); InstallAppRequest request = new InstallAppRequest(this, manifestStream, marketplaceAssetId, marketplaceContentMarket, false); - InstallAppResponse response = await request.Execute().ConfigureAwait(false); + InstallAppResponse response = await request.Execute(token).ConfigureAwait(false); return response.WasFirstInstall; } @@ -4583,13 +4735,13 @@ public System.Threading.Tasks.Task InstallApp(Stream manifestStream) /// /// App ID /// Exception will be thrown for errors. - public System.Threading.Tasks.Task UninstallApp(string id) + public System.Threading.Tasks.Task UninstallApp(string id, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(id, "id"); UninstallAppRequest request = new UninstallAppRequest(this, id); - return request.Execute(); + return request.Execute(token); } /// @@ -4598,14 +4750,14 @@ public System.Threading.Tasks.Task UninstallApp(string id) /// App ID /// Disable reason /// Exception will be thrown for errors. - public System.Threading.Tasks.Task DisableApp(string id, DisableReasonType disableReason) + public System.Threading.Tasks.Task DisableApp(string id, DisableReasonType disableReason, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(id, "id"); EwsUtilities.ValidateParam(disableReason, "disableReason"); DisableAppRequest request = new DisableAppRequest(this, id, disableReason); - return request.Execute(); + return request.Execute(token); } /// @@ -4614,14 +4766,14 @@ public System.Threading.Tasks.Task DisableApp(string id, DisableReasonType disab /// Extension id. /// Sets the consent state of an extension. /// Exception will be thrown for errors. - public System.Threading.Tasks.Task RegisterConsent(string id, ConsentState state) + public System.Threading.Tasks.Task RegisterConsent(string id, ConsentState state, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(id, "id"); EwsUtilities.ValidateParam(state, "state"); RegisterConsentRequest request = new RegisterConsentRequest(this, id, state); - return request.Execute(); + return request.Execute(token); } /// @@ -4639,13 +4791,13 @@ public Task GetAppMarketplaceUrl() /// The api version supported by the client. /// The schema version supported by the client. /// Exception will be thrown for errors. - public async Task GetAppMarketplaceUrl(string apiVersionSupported, string schemaVersionSupported) + public async Task GetAppMarketplaceUrl(string apiVersionSupported, string schemaVersionSupported, CancellationToken token = default(CancellationToken)) { GetAppMarketplaceUrlRequest request = new GetAppMarketplaceUrlRequest(this); request.ApiVersionSupported = apiVersionSupported; request.SchemaVersionSupported = schemaVersionSupported; - return (await request.Execute().ConfigureAwait(false)).AppMarketplaceUrl; + return (await request.Execute(token).ConfigureAwait(false)).AppMarketplaceUrl; } /// @@ -4677,7 +4829,8 @@ public Task GetClientExtension( string userId, StringList userEnabledExtensionIds, StringList userDisabledExtensionIds, - bool isDebug) + bool isDebug, + CancellationToken token = default(CancellationToken)) { GetClientExtensionRequest request = new GetClientExtensionRequest( this, @@ -4689,29 +4842,29 @@ public Task GetClientExtension( userDisabledExtensionIds, isDebug); - return request.Execute(); + return request.Execute(token); } /// /// Get the OME (i.e. Office Message Encryption) configuration data. This method is used in server-to-server calls to retrieve OME configuration /// /// OME Configuration response object - public Task GetOMEConfiguration() + public Task GetOMEConfiguration(CancellationToken token = default(CancellationToken)) { GetOMEConfigurationRequest request = new GetOMEConfigurationRequest(this); - return request.Execute(); + return request.Execute(token); } /// /// Set the OME (i.e. Office Message Encryption) configuration data. This method is used in server-to-server calls to set encryption configuration /// /// The xml - public System.Threading.Tasks.Task SetOMEConfiguration(string xml) + public System.Threading.Tasks.Task SetOMEConfiguration(string xml, CancellationToken token = default(CancellationToken)) { SetOMEConfigurationRequest request = new SetOMEConfigurationRequest(this, xml); - return request.Execute(); + return request.Execute(token); } /// @@ -4719,11 +4872,11 @@ public System.Threading.Tasks.Task SetOMEConfiguration(string xml) /// extensions to support admin's management of ORG extensions via powershell/UMC. /// /// List of actions to execute. - public System.Threading.Tasks.Task SetClientExtension(List actions) + public System.Threading.Tasks.Task SetClientExtension(List actions, CancellationToken token = default(CancellationToken)) { SetClientExtensionRequest request = new SetClientExtensionRequest(this, actions); - return request.ExecuteAsync(); + return request.ExecuteAsync(token); } #endregion @@ -4737,12 +4890,13 @@ public System.Threading.Tasks.Task SetClientExtension(ListUserUnified groups. public Task> GetUserUnifiedGroups( IEnumerable requestedUnifiedGroupsSets, - string userSmtpAddress) + string userSmtpAddress, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(requestedUnifiedGroupsSets, "requestedUnifiedGroupsSets"); EwsUtilities.ValidateParam(userSmtpAddress, "userSmtpAddress"); - return this.GetUserUnifiedGroupsInternal(requestedUnifiedGroupsSets, userSmtpAddress); + return this.GetUserUnifiedGroupsInternal(requestedUnifiedGroupsSets, userSmtpAddress, token); } /// @@ -4750,10 +4904,10 @@ public Task> GetUserUnifiedGroups( /// /// The Requested Unified Groups Sets /// UserUnified groups. - public Task> GetUserUnifiedGroups(IEnumerable requestedUnifiedGroupsSets) + public Task> GetUserUnifiedGroups(IEnumerable requestedUnifiedGroupsSets, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(requestedUnifiedGroupsSets, "requestedUnifiedGroupsSets"); - return this.GetUserUnifiedGroupsInternal(requestedUnifiedGroupsSets, null); + return this.GetUserUnifiedGroupsInternal(requestedUnifiedGroupsSets, null, token); } /// @@ -4764,7 +4918,7 @@ public Task> GetUserUnifiedGroups(IEnumerableUserUnified groups. private async Task> GetUserUnifiedGroupsInternal( IEnumerable requestedUnifiedGroupsSets, - string userSmtpAddress) + string userSmtpAddress, CancellationToken token) { GetUserUnifiedGroupsRequest request = new GetUserUnifiedGroupsRequest(this); @@ -4778,7 +4932,7 @@ private async Task> GetUserUnifiedGroupsInternal( request.RequestedUnifiedGroupsSets = requestedUnifiedGroupsSets; } - return (await request.Execute().ConfigureAwait(false)).GroupsSets; + return (await request.Execute(token).ConfigureAwait(false)).GroupsSets; } /// @@ -4787,7 +4941,7 @@ private async Task> GetUserUnifiedGroupsInternal( /// The smtpaddress of group for which unseendata is desired /// The LastVisitedTimeUtc of group for which unseendata is desired /// UnifiedGroupsUnseenCount - public async Task GetUnifiedGroupUnseenCount(string groupMailboxSmtpAddress, DateTime lastVisitedTimeUtc) + public async Task GetUnifiedGroupUnseenCount(string groupMailboxSmtpAddress, DateTime lastVisitedTimeUtc, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(groupMailboxSmtpAddress, "groupMailboxSmtpAddress"); @@ -4796,7 +4950,7 @@ public async Task GetUnifiedGroupUnseenCount(string groupMailboxSmtpAddress request.AnchorMailbox = groupMailboxSmtpAddress; - return (await request.Execute().ConfigureAwait(false)).UnseenCount; + return (await request.Execute(token).ConfigureAwait(false)).UnseenCount; } /// @@ -4804,13 +4958,14 @@ public async Task GetUnifiedGroupUnseenCount(string groupMailboxSmtpAddress /// /// The smtpaddress of group for which unseendata is desired /// The LastVisitedTimeUtc of group for which unseendata is desired - public System.Threading.Tasks.Task SetUnifiedGroupLastVisitedTime(string groupMailboxSmtpAddress, DateTime lastVisitedTimeUtc) + public System.Threading.Tasks.Task SetUnifiedGroupLastVisitedTime(string groupMailboxSmtpAddress, DateTime lastVisitedTimeUtc, + CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(groupMailboxSmtpAddress, "groupMailboxSmtpAddress"); SetUnifiedGroupLastVisitedTimeRequest request = new SetUnifiedGroupLastVisitedTimeRequest(this, lastVisitedTimeUtc, UnifiedGroupIdentityType.SmtpAddress, groupMailboxSmtpAddress); - return request.Execute(); + return request.Execute(token); } #endregion @@ -4823,13 +4978,13 @@ public System.Threading.Tasks.Task SetUnifiedGroupLastVisitedTime(string groupMa /// The verb. /// The parameter. /// - internal async Task ExecuteDiagnosticMethod(string verb, XmlNode parameter) + internal async Task ExecuteDiagnosticMethod(string verb, XmlNode parameter, CancellationToken token) { ExecuteDiagnosticMethodRequest request = new ExecuteDiagnosticMethodRequest(this); request.Verb = verb; request.Parameter = parameter; - return (await request.ExecuteAsync().ConfigureAwait(false))[0].ReturnValue; + return (await request.ExecuteAsync(token).ConfigureAwait(false))[0].ReturnValue; } #endregion diff --git a/Core/Requests/DelegateManagementRequestBase.cs b/Core/Requests/DelegateManagementRequestBase.cs index c14999b1..3f9ee856 100644 --- a/Core/Requests/DelegateManagementRequestBase.cs +++ b/Core/Requests/DelegateManagementRequestBase.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -93,9 +94,9 @@ internal override object ParseResponse(EwsServiceXmlReader reader) /// Executes this request. /// /// Response object. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - TResponse serviceResponse = (TResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + TResponse serviceResponse = (TResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); diff --git a/Core/Requests/DisableAppRequest.cs b/Core/Requests/DisableAppRequest.cs index 09e4ac8a..35cb49f1 100644 --- a/Core/Requests/DisableAppRequest.cs +++ b/Core/Requests/DisableAppRequest.cs @@ -29,6 +29,7 @@ namespace Microsoft.Exchange.WebServices.Data using System.Collections.Generic; using System.IO; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -128,9 +129,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - DisableAppResponse serviceResponse = (DisableAppResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + DisableAppResponse serviceResponse = (DisableAppResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/DisconnectPhoneCallRequest.cs b/Core/Requests/DisconnectPhoneCallRequest.cs index ece8f45f..59431b0c 100644 --- a/Core/Requests/DisconnectPhoneCallRequest.cs +++ b/Core/Requests/DisconnectPhoneCallRequest.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -98,9 +99,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - ServiceResponse serviceResponse = (ServiceResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + ServiceResponse serviceResponse = (ServiceResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/FindConversationRequest.cs b/Core/Requests/FindConversationRequest.cs index 65305cee..0236781e 100644 --- a/Core/Requests/FindConversationRequest.cs +++ b/Core/Requests/FindConversationRequest.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -293,9 +294,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - FindConversationResponse serviceResponse = (FindConversationResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + FindConversationResponse serviceResponse = (FindConversationResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/FindPeopleRequest.cs b/Core/Requests/FindPeopleRequest.cs index 3fa11371..a4b2821f 100644 --- a/Core/Requests/FindPeopleRequest.cs +++ b/Core/Requests/FindPeopleRequest.cs @@ -27,6 +27,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; using System.Collections.Generic; + using System.Threading; using System.Threading.Tasks; /// @@ -224,9 +225,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - FindPeopleResponse serviceResponse = (FindPeopleResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + FindPeopleResponse serviceResponse = (FindPeopleResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/GetAppManifestsRequest.cs b/Core/Requests/GetAppManifestsRequest.cs index 2751a1b9..7f5f4f52 100644 --- a/Core/Requests/GetAppManifestsRequest.cs +++ b/Core/Requests/GetAppManifestsRequest.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -136,9 +137,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - GetAppManifestsResponse serviceResponse = (GetAppManifestsResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + GetAppManifestsResponse serviceResponse = (GetAppManifestsResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/GetAppMarketplaceUrlRequest.cs b/Core/Requests/GetAppMarketplaceUrlRequest.cs index f8dab7e0..98ad1e71 100644 --- a/Core/Requests/GetAppMarketplaceUrlRequest.cs +++ b/Core/Requests/GetAppMarketplaceUrlRequest.cs @@ -29,6 +29,7 @@ namespace Microsoft.Exchange.WebServices.Data using System.Collections.Generic; using System.IO; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -137,9 +138,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - GetAppMarketplaceUrlResponse serviceResponse = (GetAppMarketplaceUrlResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + GetAppMarketplaceUrlResponse serviceResponse = (GetAppMarketplaceUrlResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/GetClientExtensionRequest.cs b/Core/Requests/GetClientExtensionRequest.cs index fdd7358f..cc0bb22f 100644 --- a/Core/Requests/GetClientExtensionRequest.cs +++ b/Core/Requests/GetClientExtensionRequest.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -199,9 +200,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - GetClientExtensionResponse serviceResponse = (GetClientExtensionResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + GetClientExtensionResponse serviceResponse = (GetClientExtensionResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/GetDiscoverySearchConfigurationRequest.cs b/Core/Requests/GetDiscoverySearchConfigurationRequest.cs index cf9f83f3..23ac048f 100644 --- a/Core/Requests/GetDiscoverySearchConfigurationRequest.cs +++ b/Core/Requests/GetDiscoverySearchConfigurationRequest.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -98,9 +99,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - GetDiscoverySearchConfigurationResponse serviceResponse = (GetDiscoverySearchConfigurationResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + GetDiscoverySearchConfigurationResponse serviceResponse = (GetDiscoverySearchConfigurationResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); return serviceResponse; } diff --git a/Core/Requests/GetHoldOnMailboxesRequest.cs b/Core/Requests/GetHoldOnMailboxesRequest.cs index e6544103..adaa9f67 100644 --- a/Core/Requests/GetHoldOnMailboxesRequest.cs +++ b/Core/Requests/GetHoldOnMailboxesRequest.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -109,9 +110,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - GetHoldOnMailboxesResponse serviceResponse = (GetHoldOnMailboxesResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + GetHoldOnMailboxesResponse serviceResponse = (GetHoldOnMailboxesResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); return serviceResponse; } diff --git a/Core/Requests/GetInboxRulesRequest.cs b/Core/Requests/GetInboxRulesRequest.cs index 1a58c229..5cdecf5f 100644 --- a/Core/Requests/GetInboxRulesRequest.cs +++ b/Core/Requests/GetInboxRulesRequest.cs @@ -23,6 +23,7 @@ * DEALINGS IN THE SOFTWARE. */ +using System.Threading; using System.Threading.Tasks; namespace Microsoft.Exchange.WebServices.Data @@ -113,9 +114,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - GetInboxRulesResponse serviceResponse = (GetInboxRulesResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + GetInboxRulesResponse serviceResponse = (GetInboxRulesResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/GetNonIndexableItemDetailsRequest.cs b/Core/Requests/GetNonIndexableItemDetailsRequest.cs index 32fe98bb..2651396d 100644 --- a/Core/Requests/GetNonIndexableItemDetailsRequest.cs +++ b/Core/Requests/GetNonIndexableItemDetailsRequest.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -132,9 +133,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - GetNonIndexableItemDetailsResponse serviceResponse = (GetNonIndexableItemDetailsResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + GetNonIndexableItemDetailsResponse serviceResponse = (GetNonIndexableItemDetailsResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); return serviceResponse; } diff --git a/Core/Requests/GetNonIndexableItemStatisticsRequest.cs b/Core/Requests/GetNonIndexableItemStatisticsRequest.cs index 74e7d894..c7a6183e 100644 --- a/Core/Requests/GetNonIndexableItemStatisticsRequest.cs +++ b/Core/Requests/GetNonIndexableItemStatisticsRequest.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -117,9 +118,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - GetNonIndexableItemStatisticsResponse serviceResponse = (GetNonIndexableItemStatisticsResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + GetNonIndexableItemStatisticsResponse serviceResponse = (GetNonIndexableItemStatisticsResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); return serviceResponse; } diff --git a/Core/Requests/GetOMEConfigurationRequest.cs b/Core/Requests/GetOMEConfigurationRequest.cs index ceb01714..8dcfe001 100644 --- a/Core/Requests/GetOMEConfigurationRequest.cs +++ b/Core/Requests/GetOMEConfigurationRequest.cs @@ -23,6 +23,7 @@ * DEALINGS IN THE SOFTWARE. */ +using System.Threading; using System.Threading.Tasks; namespace Microsoft.Exchange.WebServices.Data @@ -93,9 +94,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - GetOMEConfigurationResponse serviceResponse = (GetOMEConfigurationResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + GetOMEConfigurationResponse serviceResponse = (GetOMEConfigurationResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/GetPasswordExpirationDateRequest.cs b/Core/Requests/GetPasswordExpirationDateRequest.cs index d2133090..d133e750 100644 --- a/Core/Requests/GetPasswordExpirationDateRequest.cs +++ b/Core/Requests/GetPasswordExpirationDateRequest.cs @@ -27,6 +27,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -95,9 +96,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - GetPasswordExpirationDateResponse serviceResponse = (GetPasswordExpirationDateResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + GetPasswordExpirationDateResponse serviceResponse = (GetPasswordExpirationDateResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/GetPeopleInsightsRequest.cs b/Core/Requests/GetPeopleInsightsRequest.cs index 1993ed31..198db217 100644 --- a/Core/Requests/GetPeopleInsightsRequest.cs +++ b/Core/Requests/GetPeopleInsightsRequest.cs @@ -32,6 +32,7 @@ namespace Microsoft.Exchange.WebServices.Data using Microsoft.Exchange.WebServices.Data.Enumerations; using System.Threading.Tasks; + using System.Threading; /// /// Represents a GetPeopleInsights request. @@ -127,9 +128,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - GetPeopleInsightsResponse serviceResponse = (GetPeopleInsightsResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + GetPeopleInsightsResponse serviceResponse = (GetPeopleInsightsResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/GetPhoneCallRequest.cs b/Core/Requests/GetPhoneCallRequest.cs index 1deaa8bd..1c2067b1 100644 --- a/Core/Requests/GetPhoneCallRequest.cs +++ b/Core/Requests/GetPhoneCallRequest.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -98,9 +99,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - GetPhoneCallResponse serviceResponse = (GetPhoneCallResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + GetPhoneCallResponse serviceResponse = (GetPhoneCallResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/GetRoomListsRequest.cs b/Core/Requests/GetRoomListsRequest.cs index bbea5c49..15dd1c2c 100644 --- a/Core/Requests/GetRoomListsRequest.cs +++ b/Core/Requests/GetRoomListsRequest.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -96,9 +97,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - GetRoomListsResponse serviceResponse = (GetRoomListsResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + GetRoomListsResponse serviceResponse = (GetRoomListsResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/GetRoomsRequest.cs b/Core/Requests/GetRoomsRequest.cs index a848e725..65140df5 100644 --- a/Core/Requests/GetRoomsRequest.cs +++ b/Core/Requests/GetRoomsRequest.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -96,9 +97,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - GetRoomsResponse serviceResponse = (GetRoomsResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + GetRoomsResponse serviceResponse = (GetRoomsResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/GetSearchableMailboxesRequest.cs b/Core/Requests/GetSearchableMailboxesRequest.cs index 13e2af11..7edde41a 100644 --- a/Core/Requests/GetSearchableMailboxesRequest.cs +++ b/Core/Requests/GetSearchableMailboxesRequest.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -97,9 +98,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - GetSearchableMailboxesResponse serviceResponse = (GetSearchableMailboxesResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + GetSearchableMailboxesResponse serviceResponse = (GetSearchableMailboxesResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); return serviceResponse; } diff --git a/Core/Requests/GetUserAvailabilityRequest.cs b/Core/Requests/GetUserAvailabilityRequest.cs index 2146c9c8..350e0508 100644 --- a/Core/Requests/GetUserAvailabilityRequest.cs +++ b/Core/Requests/GetUserAvailabilityRequest.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -197,9 +198,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - return (GetUserAvailabilityResults)await this.InternalExecuteAsync().ConfigureAwait(false); + return (GetUserAvailabilityResults)await this.InternalExecuteAsync(token).ConfigureAwait(false); } /// diff --git a/Core/Requests/GetUserOofSettingsRequest.cs b/Core/Requests/GetUserOofSettingsRequest.cs index 5fa5271a..ccbb2e28 100644 --- a/Core/Requests/GetUserOofSettingsRequest.cs +++ b/Core/Requests/GetUserOofSettingsRequest.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -124,9 +125,9 @@ internal GetUserOofSettingsRequest(ExchangeService service) /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - GetUserOofSettingsResponse serviceResponse = (GetUserOofSettingsResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + GetUserOofSettingsResponse serviceResponse = (GetUserOofSettingsResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); diff --git a/Core/Requests/GetUserPhotoRequest.cs b/Core/Requests/GetUserPhotoRequest.cs index b07429c3..ba3adb16 100644 --- a/Core/Requests/GetUserPhotoRequest.cs +++ b/Core/Requests/GetUserPhotoRequest.cs @@ -30,6 +30,7 @@ namespace Microsoft.Exchange.WebServices.Data using Microsoft.Exchange.WebServices.Data; using System.Threading.Tasks; using System.Net.Http.Headers; + using System.Threading; /// /// Represents a request of a get user photo operation @@ -184,9 +185,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal Task Execute() + internal Task Execute(CancellationToken token) { - return GetUserPhotoRequest.GetResultOrDefault(this.InternalExecuteAsync); + return GetUserPhotoRequest.GetResultOrDefault(() => this.InternalExecuteAsync(token)); } /// diff --git a/Core/Requests/GetUserRetentionPolicyTagsRequest.cs b/Core/Requests/GetUserRetentionPolicyTagsRequest.cs index edaa7b96..43cbaaa5 100644 --- a/Core/Requests/GetUserRetentionPolicyTagsRequest.cs +++ b/Core/Requests/GetUserRetentionPolicyTagsRequest.cs @@ -27,6 +27,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -95,9 +96,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - GetUserRetentionPolicyTagsResponse serviceResponse = (GetUserRetentionPolicyTagsResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + GetUserRetentionPolicyTagsResponse serviceResponse = (GetUserRetentionPolicyTagsResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); return serviceResponse; } } diff --git a/Core/Requests/HangingServiceRequestBase.cs b/Core/Requests/HangingServiceRequestBase.cs index 39e5c59c..0a52f9ed 100644 --- a/Core/Requests/HangingServiceRequestBase.cs +++ b/Core/Requests/HangingServiceRequestBase.cs @@ -162,11 +162,11 @@ internal HangingServiceRequestBase(ExchangeService service, HandleResponseObject /// /// Exectures the request. /// - internal void InternalExecute() + internal void InternalExecute(CancellationToken token) { lock (this.lockObject) { - var tuple = this.ValidateAndEmitRequest().Result; + var tuple = this.ValidateAndEmitRequest(token).Result; this.request = tuple.Item1; this.response = tuple.Item2; diff --git a/Core/Requests/InstallAppRequest.cs b/Core/Requests/InstallAppRequest.cs index 81b246cf..13dba8a2 100644 --- a/Core/Requests/InstallAppRequest.cs +++ b/Core/Requests/InstallAppRequest.cs @@ -29,6 +29,7 @@ namespace Microsoft.Exchange.WebServices.Data using System.Collections.Generic; using System.IO; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -121,9 +122,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - InstallAppResponse serviceResponse = (InstallAppResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + InstallAppResponse serviceResponse = (InstallAppResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/MultiResponseServiceRequest.cs b/Core/Requests/MultiResponseServiceRequest.cs index 488316d3..eb6fef9a 100644 --- a/Core/Requests/MultiResponseServiceRequest.cs +++ b/Core/Requests/MultiResponseServiceRequest.cs @@ -26,6 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; + using System.Threading; using System.Threading.Tasks; /// @@ -128,9 +129,9 @@ internal MultiResponseServiceRequest(ExchangeService service, ServiceErrorHandli /// Executes this request. /// /// Service response collection. - internal async Task> ExecuteAsync() + internal async Task> ExecuteAsync(CancellationToken token) { - ServiceResponseCollection serviceResponses = (ServiceResponseCollection)await this.InternalExecuteAsync().ConfigureAwait(false); + ServiceResponseCollection serviceResponses = (ServiceResponseCollection)await this.InternalExecuteAsync(token).ConfigureAwait(false); if (this.ErrorHandlingMode == ServiceErrorHandling.ThrowOnError) { diff --git a/Core/Requests/PlayOnPhoneRequest.cs b/Core/Requests/PlayOnPhoneRequest.cs index 5aff5099..2bb1d478 100644 --- a/Core/Requests/PlayOnPhoneRequest.cs +++ b/Core/Requests/PlayOnPhoneRequest.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -100,9 +101,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - PlayOnPhoneResponse serviceResponse = (PlayOnPhoneResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + PlayOnPhoneResponse serviceResponse = (PlayOnPhoneResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/RegisterConsentRequest.cs b/Core/Requests/RegisterConsentRequest.cs index 631fb85b..160c9f63 100644 --- a/Core/Requests/RegisterConsentRequest.cs +++ b/Core/Requests/RegisterConsentRequest.cs @@ -32,6 +32,7 @@ namespace Microsoft.Exchange.WebServices.Data using Microsoft.Exchange.WebServices.Data.Enumerations; using System.Threading.Tasks; + using System.Threading; /// /// Represents a RegisterConsent request. @@ -122,9 +123,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - RegisterConsentResponse serviceResponse = (RegisterConsentResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + RegisterConsentResponse serviceResponse = (RegisterConsentResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/ServiceRequestBase.cs b/Core/Requests/ServiceRequestBase.cs index cdc4bdc2..e411fe41 100644 --- a/Core/Requests/ServiceRequestBase.cs +++ b/Core/Requests/ServiceRequestBase.cs @@ -650,7 +650,7 @@ protected SoapFaultDetails ReadSoapFault(EwsServiceXmlReader reader) /// /// The request. /// The response returned by the server. - protected async Task> ValidateAndEmitRequest() + protected async Task> ValidateAndEmitRequest(CancellationToken token) { this.Validate(); @@ -681,7 +681,7 @@ protected async Task> ValidateAnd try { - response = await this.GetEwsHttpWebResponse(request).ConfigureAwait(false); + response = await this.GetEwsHttpWebResponse(request, token).ConfigureAwait(false); } finally { @@ -787,11 +787,11 @@ protected async Task BuildEwsHttpWebRequest() /// /// The specified IEwsHttpWebRequest /// An IEwsHttpWebResponse instance - protected async Task GetEwsHttpWebResponse(IEwsHttpWebRequest request) + protected async Task GetEwsHttpWebResponse(IEwsHttpWebRequest request, CancellationToken token) { try { - return await request.GetResponse().ConfigureAwait(false); + return await request.GetResponse(token).ConfigureAwait(false); } catch (EwsHttpClientException ex) { diff --git a/Core/Requests/SetHoldOnMailboxesRequest.cs b/Core/Requests/SetHoldOnMailboxesRequest.cs index 64beb182..b7de4c82 100644 --- a/Core/Requests/SetHoldOnMailboxesRequest.cs +++ b/Core/Requests/SetHoldOnMailboxesRequest.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -133,9 +134,9 @@ internal override void WriteElementsToXml(EwsServiceXmlWriter writer) /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - SetHoldOnMailboxesResponse serviceResponse = (SetHoldOnMailboxesResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + SetHoldOnMailboxesResponse serviceResponse = (SetHoldOnMailboxesResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); return serviceResponse; } diff --git a/Core/Requests/SetOMEConfigurationRequest.cs b/Core/Requests/SetOMEConfigurationRequest.cs index bd8d64b4..881c2f7d 100644 --- a/Core/Requests/SetOMEConfigurationRequest.cs +++ b/Core/Requests/SetOMEConfigurationRequest.cs @@ -23,6 +23,7 @@ * DEALINGS IN THE SOFTWARE. */ +using System.Threading; using System.Threading.Tasks; namespace Microsoft.Exchange.WebServices.Data @@ -107,9 +108,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - SetOMEConfigurationResponse serviceResponse = (SetOMEConfigurationResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + SetOMEConfigurationResponse serviceResponse = (SetOMEConfigurationResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/SetTeamMailboxRequest.cs b/Core/Requests/SetTeamMailboxRequest.cs index 75314fb7..a1718349 100644 --- a/Core/Requests/SetTeamMailboxRequest.cs +++ b/Core/Requests/SetTeamMailboxRequest.cs @@ -26,6 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; + using System.Threading; using System.Threading.Tasks; /// @@ -127,9 +128,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - ServiceResponse serviceResponse = (ServiceResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + ServiceResponse serviceResponse = (ServiceResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/SetUserOofSettingsRequest.cs b/Core/Requests/SetUserOofSettingsRequest.cs index cced4db0..9eae6ec1 100644 --- a/Core/Requests/SetUserOofSettingsRequest.cs +++ b/Core/Requests/SetUserOofSettingsRequest.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -116,9 +117,9 @@ internal SetUserOofSettingsRequest(ExchangeService service) /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - ServiceResponse serviceResponse = (ServiceResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + ServiceResponse serviceResponse = (ServiceResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); diff --git a/Core/Requests/SetUserPhotoRequest.cs b/Core/Requests/SetUserPhotoRequest.cs index bc39f08b..f6bb7037 100644 --- a/Core/Requests/SetUserPhotoRequest.cs +++ b/Core/Requests/SetUserPhotoRequest.cs @@ -30,6 +30,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Net; using System.Net.Http.Headers; + using System.Threading; using Microsoft.Exchange.WebServices.Data; /// @@ -151,9 +152,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal SetUserPhotoResponse Execute() + internal SetUserPhotoResponse Execute(CancellationToken token) { - return SetUserPhotoRequest.SetResultOrDefault(this.InternalExecuteAsync); + return SetUserPhotoRequest.SetResultOrDefault(() => this.InternalExecuteAsync(token)); } private static SetUserPhotoResponse SetResultOrDefault(Func serviceResponseFactory) diff --git a/Core/Requests/SimpleServiceRequestBase.cs b/Core/Requests/SimpleServiceRequestBase.cs index bb9d7c86..e083d049 100644 --- a/Core/Requests/SimpleServiceRequestBase.cs +++ b/Core/Requests/SimpleServiceRequestBase.cs @@ -30,6 +30,7 @@ namespace Microsoft.Exchange.WebServices.Data using System.IO.Compression; using System.Net; using System.Net.Http.Headers; + using System.Threading; using System.Threading.Tasks; using System.Xml; @@ -51,9 +52,9 @@ internal SimpleServiceRequestBase(ExchangeService service) : /// Executes this request. /// /// Service response. - internal async Task InternalExecuteAsync() + internal async Task InternalExecuteAsync(CancellationToken token) { - var tuple = await this.ValidateAndEmitRequest().ConfigureAwait(false); + var tuple = await this.ValidateAndEmitRequest(token).ConfigureAwait(false); try { return await this.ReadResponse(tuple.Item2); diff --git a/Core/Requests/UninstallAppRequest.cs b/Core/Requests/UninstallAppRequest.cs index 55f612de..2e8b9449 100644 --- a/Core/Requests/UninstallAppRequest.cs +++ b/Core/Requests/UninstallAppRequest.cs @@ -29,6 +29,7 @@ namespace Microsoft.Exchange.WebServices.Data using System.Collections.Generic; using System.IO; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -99,9 +100,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - UninstallAppResponse serviceResponse = (UninstallAppResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + UninstallAppResponse serviceResponse = (UninstallAppResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/UnpinTeamMailboxRequest.cs b/Core/Requests/UnpinTeamMailboxRequest.cs index ab17cdb5..c50f03c7 100644 --- a/Core/Requests/UnpinTeamMailboxRequest.cs +++ b/Core/Requests/UnpinTeamMailboxRequest.cs @@ -26,6 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; + using System.Threading; using System.Threading.Tasks; /// @@ -106,9 +107,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - ServiceResponse serviceResponse = (ServiceResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + ServiceResponse serviceResponse = (ServiceResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); serviceResponse.ThrowIfNecessary(); return serviceResponse; } diff --git a/Core/Requests/UpdateInboxRulesRequest.cs b/Core/Requests/UpdateInboxRulesRequest.cs index ab944fab..147d2660 100644 --- a/Core/Requests/UpdateInboxRulesRequest.cs +++ b/Core/Requests/UpdateInboxRulesRequest.cs @@ -27,6 +27,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; using System.Collections.Generic; + using System.Threading; using System.Threading.Tasks; /// @@ -152,9 +153,9 @@ internal override void Validate() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - UpdateInboxRulesResponse serviceResponse = (UpdateInboxRulesResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + UpdateInboxRulesResponse serviceResponse = (UpdateInboxRulesResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); if (serviceResponse.Result == ServiceResult.Error) { throw new UpdateInboxRulesException(serviceResponse, this.inboxRuleOperations.GetEnumerator()); diff --git a/Core/ServiceObjects/Folders/CalendarFolder.cs b/Core/ServiceObjects/Folders/CalendarFolder.cs index 9bef4c66..3134fbdd 100644 --- a/Core/ServiceObjects/Folders/CalendarFolder.cs +++ b/Core/ServiceObjects/Folders/CalendarFolder.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -47,9 +48,10 @@ public class CalendarFolder : Folder public static new Task Bind( ExchangeService service, FolderId id, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { - return service.BindToFolder(id, propertySet); + return service.BindToFolder(id, propertySet, token); } /// @@ -116,14 +118,15 @@ public CalendarFolder(ExchangeService service) /// /// The view controlling the range of appointments returned. /// An object representing the results of the search operation. - public async Task> FindAppointments(CalendarView view) + public async Task> FindAppointments(CalendarView view, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(view, "view"); ServiceResponseCollection> responses = await this.InternalFindItems( (SearchFilter)null, view, - null /* groupBy */).ConfigureAwait(false); + null /* groupBy */, + token).ConfigureAwait(false); return responses[0].Results; } diff --git a/Core/ServiceObjects/Folders/ContactsFolder.cs b/Core/ServiceObjects/Folders/ContactsFolder.cs index 96fb0a38..9fb491c6 100644 --- a/Core/ServiceObjects/Folders/ContactsFolder.cs +++ b/Core/ServiceObjects/Folders/ContactsFolder.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -55,9 +56,10 @@ public ContactsFolder(ExchangeService service) public static new Task Bind( ExchangeService service, FolderId id, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { - return service.BindToFolder(id, propertySet); + return service.BindToFolder(id, propertySet, token); } /// diff --git a/Core/ServiceObjects/Folders/Folder.cs b/Core/ServiceObjects/Folders/Folder.cs index 2a507a53..cb56f720 100644 --- a/Core/ServiceObjects/Folders/Folder.cs +++ b/Core/ServiceObjects/Folders/Folder.cs @@ -26,6 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System.Collections.Generic; + using System.Threading; using System.Threading.Tasks; /// @@ -54,9 +55,10 @@ public Folder(ExchangeService service) public static Task Bind( ExchangeService service, FolderId id, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { - return service.BindToFolder(id, propertySet); + return service.BindToFolder(id, propertySet, token); } /// @@ -171,11 +173,11 @@ internal override string GetDeleteFieldXmlElementName() /// Loads the specified set of properties on the object. /// /// The properties to load. - internal override Task> InternalLoad(PropertySet propertySet) + internal override Task> InternalLoad(PropertySet propertySet, CancellationToken token) { this.ThrowIfThisIsNew(); - return this.Service.LoadPropertiesForFolder(this, propertySet); + return this.Service.LoadPropertiesForFolder(this, propertySet, token); } /// @@ -187,20 +189,21 @@ internal override Task> InternalLoad( internal override Task> InternalDelete( DeleteMode deleteMode, SendCancellationsMode? sendCancellationsMode, - AffectedTaskOccurrence? affectedTaskOccurrences) + AffectedTaskOccurrence? affectedTaskOccurrences, + CancellationToken token) { this.ThrowIfThisIsNew(); - return this.Service.DeleteFolder( this.Id, deleteMode); + return this.Service.DeleteFolder( this.Id, deleteMode, token); } /// /// Deletes the folder. Calling this method results in a call to EWS. /// /// Deletion mode. - public Task> Delete(DeleteMode deleteMode) + public Task> Delete(DeleteMode deleteMode, CancellationToken token = default(CancellationToken)) { - return this.InternalDelete(deleteMode, null, null); + return this.InternalDelete(deleteMode, null, null, token); } /// @@ -210,46 +213,50 @@ public Task> Delete(DeleteMode delete /// Indicates whether sub-folders should also be deleted. public Task> Empty( DeleteMode deleteMode, - bool deleteSubFolders) + bool deleteSubFolders, + CancellationToken token = default(CancellationToken)) { this.ThrowIfThisIsNew(); return this.Service.EmptyFolder( this.Id, deleteMode, - deleteSubFolders); + deleteSubFolders, + token); } /// /// Marks all items in folder as read. Calling this method results in a call to EWS. /// /// If true, suppress sending read receipts for items. - public Task> MarkAllItemsAsRead(bool suppressReadReceipts) + public Task> MarkAllItemsAsRead(bool suppressReadReceipts, CancellationToken token = default(CancellationToken)) { this.ThrowIfThisIsNew(); return this.Service.MarkAllItemsAsRead( this.Id, true, - suppressReadReceipts); + suppressReadReceipts, + token); } /// /// Marks all items in folder as read. Calling this method results in a call to EWS. /// /// If true, suppress sending read receipts for items. - public Task> MarkAllItemsAsUnread(bool suppressReadReceipts) + public Task> MarkAllItemsAsUnread(bool suppressReadReceipts, CancellationToken token = default(CancellationToken)) { this.ThrowIfThisIsNew(); return this.Service.MarkAllItemsAsRead( this.Id, false, - suppressReadReceipts); + suppressReadReceipts, + token); } /// /// Saves this folder in a specific folder. Calling this method results in a call to EWS. /// /// The Id of the folder in which to save this folder. - public async System.Threading.Tasks.Task Save(FolderId parentFolderId) + public async System.Threading.Tasks.Task Save(FolderId parentFolderId, CancellationToken token = default(CancellationToken)) { this.ThrowIfThisIsNotNew(); @@ -257,7 +264,7 @@ public async System.Threading.Tasks.Task Save(FolderId parentFolderId) if (this.IsDirty) { - await this.Service.CreateFolder(this, parentFolderId); + await this.Service.CreateFolder(this, parentFolderId, token); } } @@ -273,13 +280,13 @@ public System.Threading.Tasks.Task Save(WellKnownFolderName parentFolderName) /// /// Applies the local changes that have been made to this folder. Calling this method results in a call to EWS. /// - public async System.Threading.Tasks.Task Update() + public async System.Threading.Tasks.Task Update(CancellationToken token = default(CancellationToken)) { if (this.IsDirty) { if (this.PropertyBag.GetIsUpdateCallNecessary()) { - await this.Service.UpdateFolder(this); + await this.Service.UpdateFolder(this, token); } } } @@ -289,13 +296,13 @@ public async System.Threading.Tasks.Task Update() /// /// The Id of the folder in which to copy this folder. /// A Folder representing the copy of this folder. - public Task Copy(FolderId destinationFolderId) + public Task Copy(FolderId destinationFolderId, CancellationToken token = default(CancellationToken)) { this.ThrowIfThisIsNew(); EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId"); - return this.Service.CopyFolder(this.Id, destinationFolderId); + return this.Service.CopyFolder(this.Id, destinationFolderId, token); } /// @@ -313,13 +320,13 @@ public Task Copy(WellKnownFolderName destinationFolderName) /// /// The Id of the folder in which to move this folder. /// A new folder representing this folder in its new location. After Move completes, this folder does not exist anymore. - public Task Move(FolderId destinationFolderId) + public Task Move(FolderId destinationFolderId, CancellationToken token = default(CancellationToken)) { this.ThrowIfThisIsNew(); EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId"); - return this.Service.MoveFolder(this.Id, destinationFolderId); + return this.Service.MoveFolder(this.Id, destinationFolderId, token); } /// @@ -343,7 +350,8 @@ public Task Move(WellKnownFolderName destinationFolderName) internal Task>> InternalFindItems( string queryString, ViewBase view, - Grouping groupBy) + Grouping groupBy, + CancellationToken token) where TItem : Item { this.ThrowIfThisIsNew(); @@ -354,7 +362,8 @@ internal Task>> InternalFindIt queryString, view, groupBy, - ServiceErrorHandling.ThrowOnError); + ServiceErrorHandling.ThrowOnError, + token); } /// @@ -370,7 +379,8 @@ internal Task>> InternalFindIt internal Task>> InternalFindItems( SearchFilter searchFilter, ViewBase view, - Grouping groupBy) + Grouping groupBy, + CancellationToken token) where TItem : Item { this.ThrowIfThisIsNew(); @@ -381,7 +391,8 @@ internal Task>> InternalFindIt null, /* queryString */ view, groupBy, - ServiceErrorHandling.ThrowOnError); + ServiceErrorHandling.ThrowOnError, + token); } /// @@ -392,14 +403,15 @@ internal Task>> InternalFindIt /// SearchFilter.SearchFilterCollection /// The view controlling the number of items returned. /// An object representing the results of the search operation. - public async Task> FindItems(SearchFilter searchFilter, ItemView view) + public async Task> FindItems(SearchFilter searchFilter, ItemView view, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParamAllowNull(searchFilter, "searchFilter"); ServiceResponseCollection> responses = await this.InternalFindItems( searchFilter, view, - null /* groupBy */).ConfigureAwait(false); + null /* groupBy */, + token).ConfigureAwait(false); return responses[0].Results; } @@ -410,11 +422,11 @@ public async Task> FindItems(SearchFilter searchFilter, I /// query string to be used for indexed search /// The view controlling the number of items returned. /// An object representing the results of the search operation. - public async Task> FindItems(string queryString, ItemView view) + public async Task> FindItems(string queryString, ItemView view, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParamAllowNull(queryString, "queryString"); - ServiceResponseCollection> responses = await this.InternalFindItems(queryString, view, null /* groupBy */).ConfigureAwait(false); + ServiceResponseCollection> responses = await this.InternalFindItems(queryString, view, null /* groupBy */, token).ConfigureAwait(false); return responses[0].Results; } @@ -424,12 +436,12 @@ public async Task> FindItems(string queryString, ItemView /// /// The view controlling the number of items returned. /// An object representing the results of the search operation. - public async Task> FindItems(ItemView view) + public async Task> FindItems(ItemView view, CancellationToken token = default(CancellationToken)) { ServiceResponseCollection> responses = await this.InternalFindItems( (SearchFilter)null, view, - null /* groupBy */ ).ConfigureAwait(false); + null /* groupBy */ , token).ConfigureAwait(false); return responses[0].Results; } @@ -443,7 +455,7 @@ public async Task> FindItems(ItemView view) /// The view controlling the number of items returned. /// The grouping criteria. /// A collection of grouped items representing the contents of this folder. - public async Task> FindItems(SearchFilter searchFilter, ItemView view, Grouping groupBy) + public async Task> FindItems(SearchFilter searchFilter, ItemView view, Grouping groupBy, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(groupBy, "groupBy"); EwsUtilities.ValidateParamAllowNull(searchFilter, "searchFilter"); @@ -451,7 +463,8 @@ public async Task> FindItems(SearchFilter searchFi ServiceResponseCollection> responses = await this.InternalFindItems( searchFilter, view, - groupBy).ConfigureAwait(false); + groupBy, + token).ConfigureAwait(false); return responses[0].GroupedFindResults; } @@ -463,11 +476,11 @@ public async Task> FindItems(SearchFilter searchFi /// The view controlling the number of items returned. /// The grouping criteria. /// A collection of grouped items representing the contents of this folder. - public async Task> FindItems(string queryString, ItemView view, Grouping groupBy) + public async Task> FindItems(string queryString, ItemView view, Grouping groupBy, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(groupBy, "groupBy"); - ServiceResponseCollection> responses = await this.InternalFindItems(queryString, view, groupBy).ConfigureAwait(false); + ServiceResponseCollection> responses = await this.InternalFindItems(queryString, view, groupBy, token).ConfigureAwait(false); return responses[0].GroupedFindResults; } diff --git a/Core/ServiceObjects/Folders/SearchFolder.cs b/Core/ServiceObjects/Folders/SearchFolder.cs index 93cb6bf1..d550a0a7 100644 --- a/Core/ServiceObjects/Folders/SearchFolder.cs +++ b/Core/ServiceObjects/Folders/SearchFolder.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -47,9 +48,10 @@ public class SearchFolder : Folder public static new Task Bind( ExchangeService service, FolderId id, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { - return service.BindToFolder(id, propertySet); + return service.BindToFolder(id, propertySet, token); } /// diff --git a/Core/ServiceObjects/Folders/TasksFolder.cs b/Core/ServiceObjects/Folders/TasksFolder.cs index 2e59557f..4047224f 100644 --- a/Core/ServiceObjects/Folders/TasksFolder.cs +++ b/Core/ServiceObjects/Folders/TasksFolder.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -56,9 +57,10 @@ public TasksFolder(ExchangeService service) public static new Task Bind( ExchangeService service, FolderId id, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { - return service.BindToFolder(id, propertySet); + return service.BindToFolder(id, propertySet, token); } /// diff --git a/Core/ServiceObjects/Items/Appointment.cs b/Core/ServiceObjects/Items/Appointment.cs index 42d88c9b..c167adfa 100644 --- a/Core/ServiceObjects/Items/Appointment.cs +++ b/Core/ServiceObjects/Items/Appointment.cs @@ -27,6 +27,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; using System.Collections.Generic; + using System.Threading; using System.Threading.Tasks; /// @@ -83,9 +84,10 @@ internal Appointment(ItemAttachment parentAttachment, bool isNew) public static new Task Bind( ExchangeService service, ItemId id, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { - return service.BindToItem(id, propertySet); + return service.BindToItem(id, propertySet, token); } /// @@ -355,12 +357,13 @@ public System.Threading.Tasks.Task Forward(MessageBody bodyPrefix, IEnumerable /// The name of the folder in which to save this appointment. /// Specifies if and how invitations should be sent if this appointment is a meeting. - public System.Threading.Tasks.Task Save(WellKnownFolderName destinationFolderName, SendInvitationsMode sendInvitationsMode) + public System.Threading.Tasks.Task Save(WellKnownFolderName destinationFolderName, SendInvitationsMode sendInvitationsMode, CancellationToken token = default(CancellationToken)) { return this.InternalCreate( new FolderId(destinationFolderName), null, - sendInvitationsMode); + sendInvitationsMode, + token); } /// @@ -369,14 +372,15 @@ public System.Threading.Tasks.Task Save(WellKnownFolderName destinationFolderNam /// /// The Id of the folder in which to save this appointment. /// Specifies if and how invitations should be sent if this appointment is a meeting. - public System.Threading.Tasks.Task Save(FolderId destinationFolderId, SendInvitationsMode sendInvitationsMode) + public System.Threading.Tasks.Task Save(FolderId destinationFolderId, SendInvitationsMode sendInvitationsMode, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId"); return this.InternalCreate( destinationFolderId, null, - sendInvitationsMode); + sendInvitationsMode, + token); } /// @@ -384,12 +388,13 @@ public System.Threading.Tasks.Task Save(FolderId destinationFolderId, SendInvita /// Mutliple calls to EWS might be made if attachments have been added. /// /// Specifies if and how invitations should be sent if this appointment is a meeting. - public System.Threading.Tasks.Task Save(SendInvitationsMode sendInvitationsMode) + public System.Threading.Tasks.Task Save(SendInvitationsMode sendInvitationsMode, CancellationToken token = default(CancellationToken)) { return this.InternalCreate( null, null, - sendInvitationsMode); + sendInvitationsMode, + token); } /// @@ -400,13 +405,15 @@ public System.Threading.Tasks.Task Save(SendInvitationsMode sendInvitationsMode) /// Specifies if and how invitations or cancellations should be sent if this appointment is a meeting. public Task Update( ConflictResolutionMode conflictResolutionMode, - SendInvitationsOrCancellationsMode sendInvitationsOrCancellationsMode) + SendInvitationsOrCancellationsMode sendInvitationsOrCancellationsMode, + CancellationToken token = default(CancellationToken)) { return this.InternalUpdate( null, conflictResolutionMode, null, - sendInvitationsOrCancellationsMode); + sendInvitationsOrCancellationsMode, + token); } /// @@ -414,12 +421,13 @@ public Task Update( /// /// The deletion mode. /// Specifies if and how cancellations should be sent if this appointment is a meeting. - public Task> Delete(DeleteMode deleteMode, SendCancellationsMode sendCancellationsMode) + public Task> Delete(DeleteMode deleteMode, SendCancellationsMode sendCancellationsMode, CancellationToken token = default(CancellationToken)) { return this.InternalDelete( deleteMode, sendCancellationsMode, - null); + null, + token); } /// diff --git a/Core/ServiceObjects/Items/Contact.cs b/Core/ServiceObjects/Items/Contact.cs index e2c0385c..62717230 100644 --- a/Core/ServiceObjects/Items/Contact.cs +++ b/Core/ServiceObjects/Items/Contact.cs @@ -29,6 +29,7 @@ namespace Microsoft.Exchange.WebServices.Data using System.Collections.Generic; using System.IO; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -69,9 +70,10 @@ internal Contact(ItemAttachment parentAttachment) public static new Task Bind( ExchangeService service, ItemId id, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { - return service.BindToItem(id, propertySet); + return service.BindToItem(id, propertySet, token); } /// diff --git a/Core/ServiceObjects/Items/ContactGroup.cs b/Core/ServiceObjects/Items/ContactGroup.cs index a86e1b6d..02ec10c5 100644 --- a/Core/ServiceObjects/Items/ContactGroup.cs +++ b/Core/ServiceObjects/Items/ContactGroup.cs @@ -23,6 +23,7 @@ * DEALINGS IN THE SOFTWARE. */ +using System.Threading; using System.Threading.Tasks; namespace Microsoft.Exchange.WebServices.Data @@ -106,9 +107,10 @@ public GroupMemberCollection Members public static new Task Bind( ExchangeService service, ItemId id, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { - return service.BindToItem(id, propertySet); + return service.BindToItem(id, propertySet, token); } /// diff --git a/Core/ServiceObjects/Items/Conversation.cs b/Core/ServiceObjects/Items/Conversation.cs index 5502b4b4..f00aa12b 100644 --- a/Core/ServiceObjects/Items/Conversation.cs +++ b/Core/ServiceObjects/Items/Conversation.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Collections.ObjectModel; + using System.Threading; using System.Threading.Tasks; /// @@ -80,7 +81,7 @@ internal override PropertyDefinition GetIdPropertyDefinition() /// Loads the specified set of properties on the object. /// /// The properties to load. - internal override Task> InternalLoad(PropertySet propertySet) + internal override Task> InternalLoad(PropertySet propertySet, CancellationToken token) { throw new NotSupportedException(); } @@ -92,7 +93,7 @@ internal override Task> InternalLoad( /// The deletion mode. /// Indicates whether meeting cancellation messages should be sent. /// Indicate which occurrence of a recurring task should be deleted. - internal override Task> InternalDelete(DeleteMode deleteMode, SendCancellationsMode? sendCancellationsMode, AffectedTaskOccurrence? affectedTaskOccurrences) + internal override Task> InternalDelete(DeleteMode deleteMode, SendCancellationsMode? sendCancellationsMode, AffectedTaskOccurrence? affectedTaskOccurrences, CancellationToken token) { throw new NotSupportedException(); } diff --git a/Core/ServiceObjects/Items/EmailMessage.cs b/Core/ServiceObjects/Items/EmailMessage.cs index ce2a77b6..25e1db82 100644 --- a/Core/ServiceObjects/Items/EmailMessage.cs +++ b/Core/ServiceObjects/Items/EmailMessage.cs @@ -26,6 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System.Collections.Generic; + using System.Threading; using System.Threading.Tasks; /// @@ -64,9 +65,10 @@ internal EmailMessage(ItemAttachment parentAttachment) public static new Task Bind( ExchangeService service, ItemId id, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { - return service.BindToItem(id, propertySet); + return service.BindToItem(id, propertySet, token); } /// @@ -107,7 +109,7 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// /// The parent folder id. /// The message disposition. - private async System.Threading.Tasks.Task InternalSend(FolderId parentFolderId, MessageDisposition messageDisposition) + private async System.Threading.Tasks.Task InternalSend(FolderId parentFolderId, MessageDisposition messageDisposition, CancellationToken token) { this.ThrowIfThisIsAttachment(); @@ -118,7 +120,8 @@ private async System.Threading.Tasks.Task InternalSend(FolderId parentFolderId, await this.InternalCreate( parentFolderId, messageDisposition, - null); + null, + token); } else { @@ -126,9 +129,10 @@ await this.InternalCreate( await this.InternalCreate( null, // null means use the Drafts folder in the mailbox of the authenticated user. MessageDisposition.SaveOnly, - null); + null, + token); - await this.Service.SendItem(this, parentFolderId); + await this.Service.SendItem(this, parentFolderId, token); } } else @@ -149,11 +153,12 @@ await this.InternalUpdate( parentFolderId, ConflictResolutionMode.AutoResolve, messageDisposition, - null); + null, + token); } else { - await this.Service.SendItem(this, parentFolderId); + await this.Service.SendItem(this, parentFolderId, token); } } } @@ -225,9 +230,9 @@ public System.Threading.Tasks.Task Forward(MessageBody bodyPrefix, IEnumerable /// Sends this e-mail message. Calling this method results in at least one call to EWS. /// - public System.Threading.Tasks.Task Send() + public System.Threading.Tasks.Task Send(CancellationToken token = default(CancellationToken)) { - return this.InternalSend(null, MessageDisposition.SendOnly); + return this.InternalSend(null, MessageDisposition.SendOnly, token); } /// @@ -236,11 +241,11 @@ public System.Threading.Tasks.Task Send() /// results in a call to EWS. /// /// The Id of the folder in which to save the copy. - public System.Threading.Tasks.Task SendAndSaveCopy(FolderId destinationFolderId) + public System.Threading.Tasks.Task SendAndSaveCopy(FolderId destinationFolderId, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId"); - return this.InternalSend(destinationFolderId, MessageDisposition.SendAndSaveCopy); + return this.InternalSend(destinationFolderId, MessageDisposition.SendAndSaveCopy, token); } /// @@ -249,9 +254,9 @@ public System.Threading.Tasks.Task SendAndSaveCopy(FolderId destinationFolderId) /// results in a call to EWS. /// /// The name of the folder in which to save the copy. - public System.Threading.Tasks.Task SendAndSaveCopy(WellKnownFolderName destinationFolderName) + public System.Threading.Tasks.Task SendAndSaveCopy(WellKnownFolderName destinationFolderName, CancellationToken token = default(CancellationToken)) { - return this.InternalSend(new FolderId(destinationFolderName), MessageDisposition.SendAndSaveCopy); + return this.InternalSend(new FolderId(destinationFolderName), MessageDisposition.SendAndSaveCopy, token); } /// @@ -259,19 +264,19 @@ public System.Threading.Tasks.Task SendAndSaveCopy(WellKnownFolderName destinati /// message has unsaved attachments. In that case, the message must first be saved and then sent. Calling this method /// results in a call to EWS. /// - public System.Threading.Tasks.Task SendAndSaveCopy() + public System.Threading.Tasks.Task SendAndSaveCopy(CancellationToken token = default(CancellationToken)) { - return this.InternalSend(new FolderId(WellKnownFolderName.SentItems), MessageDisposition.SendAndSaveCopy); + return this.InternalSend(new FolderId(WellKnownFolderName.SentItems), MessageDisposition.SendAndSaveCopy, token); } /// /// Suppresses the read receipt on the message. Calling this method results in a call to EWS. /// - public System.Threading.Tasks.Task SuppressReadReceipt() + public System.Threading.Tasks.Task SuppressReadReceipt(CancellationToken token = default(CancellationToken)) { this.ThrowIfThisIsNew(); - return new SuppressReadReceipt(this).InternalCreate(null, null); + return new SuppressReadReceipt(this).InternalCreate(null, null, token); } #region Properties diff --git a/Core/ServiceObjects/Items/Item.cs b/Core/ServiceObjects/Items/Item.cs index 58c2c351..a9b404b4 100644 --- a/Core/ServiceObjects/Items/Item.cs +++ b/Core/ServiceObjects/Items/Item.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Linq; + using System.Threading; using System.Threading.Tasks; /// @@ -74,9 +75,10 @@ internal Item(ItemAttachment parentAttachment) public static Task Bind( ExchangeService service, ItemId id, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { - return service.BindToItem(id, propertySet); + return service.BindToItem(id, propertySet, token); } /// @@ -136,7 +138,7 @@ internal override PropertyDefinition GetIdPropertyDefinition() /// Loads the specified set of properties on the object. /// /// The properties to load. - internal override Task> InternalLoad(PropertySet propertySet) + internal override Task> InternalLoad(PropertySet propertySet, CancellationToken token) { this.ThrowIfThisIsNew(); this.ThrowIfThisIsAttachment(); @@ -144,7 +146,8 @@ internal override Task> InternalLoad( return this.Service.InternalLoadPropertiesForItems( new Item[] { this }, propertySet, - ServiceErrorHandling.ThrowOnError); + ServiceErrorHandling.ThrowOnError, + token); } /// @@ -156,9 +159,10 @@ internal override Task> InternalLoad( internal override Task> InternalDelete( DeleteMode deleteMode, SendCancellationsMode? sendCancellationsMode, - AffectedTaskOccurrence? affectedTaskOccurrences) + AffectedTaskOccurrence? affectedTaskOccurrences, + CancellationToken token) { - return this.InternalDelete(deleteMode, sendCancellationsMode, affectedTaskOccurrences, false); + return this.InternalDelete(deleteMode, sendCancellationsMode, affectedTaskOccurrences, false, token); } /// @@ -172,7 +176,8 @@ internal Task> InternalDelete( DeleteMode deleteMode, SendCancellationsMode? sendCancellationsMode, AffectedTaskOccurrence? affectedTaskOccurrences, - bool suppressReadReceipts) + bool suppressReadReceipts, + CancellationToken token) { this.ThrowIfThisIsNew(); this.ThrowIfThisIsAttachment(); @@ -194,7 +199,8 @@ internal Task> InternalDelete( deleteMode, sendCancellationsMode, affectedTaskOccurrences, - suppressReadReceipts); + suppressReadReceipts, + token); } /// @@ -206,7 +212,8 @@ internal Task> InternalDelete( internal async System.Threading.Tasks.Task InternalCreate( FolderId parentFolderId, MessageDisposition? messageDisposition, - SendInvitationsMode? sendInvitationsMode) + SendInvitationsMode? sendInvitationsMode, + CancellationToken token) { this.ThrowIfThisIsNotNew(); this.ThrowIfThisIsAttachment(); @@ -217,7 +224,8 @@ await this.Service.CreateItem( this, parentFolderId, messageDisposition, - sendInvitationsMode.HasValue ? sendInvitationsMode : this.DefaultSendInvitationsMode); + sendInvitationsMode.HasValue ? sendInvitationsMode : this.DefaultSendInvitationsMode, + token); await this.Attachments.Save(); } @@ -235,9 +243,10 @@ internal Task InternalUpdate( FolderId parentFolderId, ConflictResolutionMode conflictResolutionMode, MessageDisposition? messageDisposition, - SendInvitationsOrCancellationsMode? sendInvitationsOrCancellationsMode) + SendInvitationsOrCancellationsMode? sendInvitationsOrCancellationsMode, + CancellationToken token) { - return this.InternalUpdate(parentFolderId, conflictResolutionMode, messageDisposition, sendInvitationsOrCancellationsMode, false); + return this.InternalUpdate(parentFolderId, conflictResolutionMode, messageDisposition, sendInvitationsOrCancellationsMode, false, token); } /// @@ -254,7 +263,8 @@ internal async Task InternalUpdate( ConflictResolutionMode conflictResolutionMode, MessageDisposition? messageDisposition, SendInvitationsOrCancellationsMode? sendInvitationsOrCancellationsMode, - bool suppressReadReceipts) + bool suppressReadReceipts, + CancellationToken token) { this.ThrowIfThisIsNew(); this.ThrowIfThisIsAttachment(); @@ -269,7 +279,8 @@ internal async Task InternalUpdate( conflictResolutionMode, messageDisposition, sendInvitationsOrCancellationsMode.HasValue ? sendInvitationsOrCancellationsMode : this.DefaultSendInvitationsOrCancellationsMode, - suppressReadReceipts); + suppressReadReceipts, + token); } // Regardless of whether item is dirty or not, if it has unprocessed @@ -331,9 +342,9 @@ public Task> Delete(DeleteMode delete /// /// The deletion mode. /// Whether to suppress read receipts - public Task> Delete(DeleteMode deleteMode, bool suppressReadReceipts) + public Task> Delete(DeleteMode deleteMode, bool suppressReadReceipts, CancellationToken token = default(CancellationToken)) { - return this.InternalDelete(deleteMode, null, null, suppressReadReceipts); + return this.InternalDelete(deleteMode, null, null, suppressReadReceipts, token); } /// @@ -341,14 +352,15 @@ public Task> Delete(DeleteMode delete /// Mutliple calls to EWS might be made if attachments have been added. /// /// The Id of the folder in which to save this item. - public System.Threading.Tasks.Task Save(FolderId parentFolderId) + public System.Threading.Tasks.Task Save(FolderId parentFolderId, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(parentFolderId, "parentFolderId"); return this.InternalCreate( parentFolderId, MessageDisposition.SaveOnly, - null); + null, + token); } /// @@ -356,24 +368,26 @@ public System.Threading.Tasks.Task Save(FolderId parentFolderId) /// Mutliple calls to EWS might be made if attachments have been added. /// /// The name of the folder in which to save this item. - public System.Threading.Tasks.Task Save(WellKnownFolderName parentFolderName) + public System.Threading.Tasks.Task Save(WellKnownFolderName parentFolderName, CancellationToken token = default(CancellationToken)) { return this.InternalCreate( new FolderId(parentFolderName), MessageDisposition.SaveOnly, - null); + null, + token); } /// /// Saves this item in the default folder based on the item's type (for example, an e-mail message is saved to the Drafts folder). /// Calling this method results in at least one call to EWS. Mutliple calls to EWS might be made if attachments have been added. /// - public System.Threading.Tasks.Task Save() + public System.Threading.Tasks.Task Save(CancellationToken token = default(CancellationToken)) { return this.InternalCreate( null, MessageDisposition.SaveOnly, - null); + null, + token); } /// @@ -381,9 +395,9 @@ public System.Threading.Tasks.Task Save() /// Mutliple calls to EWS might be made if attachments have been added or removed. /// /// The conflict resolution mode. - public Task Update(ConflictResolutionMode conflictResolutionMode) + public Task Update(ConflictResolutionMode conflictResolutionMode, CancellationToken token = default(CancellationToken)) { - return this.Update(conflictResolutionMode, false); + return this.Update(conflictResolutionMode, false, token); } /// @@ -392,14 +406,15 @@ public Task Update(ConflictResolutionMode conflictResolutionMode) /// /// The conflict resolution mode. /// Whether to suppress read receipts - public Task Update(ConflictResolutionMode conflictResolutionMode, bool suppressReadReceipts) + public Task Update(ConflictResolutionMode conflictResolutionMode, bool suppressReadReceipts, CancellationToken token = default(CancellationToken)) { return this.InternalUpdate( null /* parentFolder */, conflictResolutionMode, MessageDisposition.SaveOnly, null, - suppressReadReceipts); + suppressReadReceipts, + token); } /// @@ -411,14 +426,14 @@ public Task Update(ConflictResolutionMode conflictResolutionMode, bool sup /// /// The Id of the folder in which to create a copy of this item. /// The copy of this item. - public Task Copy(FolderId destinationFolderId) + public Task Copy(FolderId destinationFolderId, CancellationToken token = default(CancellationToken)) { this.ThrowIfThisIsNew(); this.ThrowIfThisIsAttachment(); EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId"); - return this.Service.CopyItem(this.Id, destinationFolderId); + return this.Service.CopyItem(this.Id, destinationFolderId, token); } /// @@ -444,14 +459,14 @@ public Task Copy(WellKnownFolderName destinationFolderName) /// /// The Id of the folder to which to move this item. /// The moved copy of this item. - public Task Move(FolderId destinationFolderId) + public Task Move(FolderId destinationFolderId, CancellationToken token = default(CancellationToken)) { this.ThrowIfThisIsNew(); this.ThrowIfThisIsAttachment(); EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId"); - return this.Service.MoveItem(this.Id, destinationFolderId); + return this.Service.MoveItem(this.Id, destinationFolderId, token); } /// diff --git a/Core/ServiceObjects/Items/MeetingCancellation.cs b/Core/ServiceObjects/Items/MeetingCancellation.cs index 5b4f02f9..06fe8a12 100644 --- a/Core/ServiceObjects/Items/MeetingCancellation.cs +++ b/Core/ServiceObjects/Items/MeetingCancellation.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -65,9 +66,10 @@ internal MeetingCancellation(ExchangeService service) public static new Task Bind( ExchangeService service, ItemId id, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { - return service.BindToItem(id, propertySet); + return service.BindToItem(id, propertySet, token); } /// @@ -101,9 +103,9 @@ internal override ServiceObjectSchema GetSchema() /// A CalendarActionResults object containing the various items that were created or modified as a /// results of this operation. /// - public async Task RemoveMeetingFromCalendar() + public async Task RemoveMeetingFromCalendar(CancellationToken token = default(CancellationToken)) { - return new CalendarActionResults(await new RemoveFromCalendar(this).InternalCreate(null, null).ConfigureAwait(false)); + return new CalendarActionResults(await new RemoveFromCalendar(this).InternalCreate(null, null, token).ConfigureAwait(false)); } /// diff --git a/Core/ServiceObjects/Items/MeetingMessage.cs b/Core/ServiceObjects/Items/MeetingMessage.cs index 7b31b110..e0ff3593 100644 --- a/Core/ServiceObjects/Items/MeetingMessage.cs +++ b/Core/ServiceObjects/Items/MeetingMessage.cs @@ -27,6 +27,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; using System.ComponentModel; + using System.Threading; using System.Threading.Tasks; /// @@ -65,9 +66,10 @@ internal MeetingMessage(ExchangeService service) public static new Task Bind( ExchangeService service, ItemId id, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { - return service.BindToItem(id, propertySet); + return service.BindToItem(id, propertySet, token); } /// diff --git a/Core/ServiceObjects/Items/MeetingRequest.cs b/Core/ServiceObjects/Items/MeetingRequest.cs index a3733aff..de1865ab 100644 --- a/Core/ServiceObjects/Items/MeetingRequest.cs +++ b/Core/ServiceObjects/Items/MeetingRequest.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -65,9 +66,10 @@ internal MeetingRequest(ExchangeService service) public static new Task Bind( ExchangeService service, ItemId id, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { - return service.BindToItem(id, propertySet); + return service.BindToItem(id, propertySet, token); } /// diff --git a/Core/ServiceObjects/Items/MeetingResponse.cs b/Core/ServiceObjects/Items/MeetingResponse.cs index 113ff922..973922b3 100644 --- a/Core/ServiceObjects/Items/MeetingResponse.cs +++ b/Core/ServiceObjects/Items/MeetingResponse.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -65,9 +66,10 @@ internal MeetingResponse(ExchangeService service) public static new Task Bind( ExchangeService service, ItemId id, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { - return service.BindToItem(id, propertySet); + return service.BindToItem(id, propertySet, token); } /// diff --git a/Core/ServiceObjects/Items/Persona.cs b/Core/ServiceObjects/Items/Persona.cs index 28a10fdd..f604686c 100644 --- a/Core/ServiceObjects/Items/Persona.cs +++ b/Core/ServiceObjects/Items/Persona.cs @@ -26,6 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; + using System.Threading; using System.Threading.Tasks; /// @@ -77,9 +78,10 @@ public Persona(ExchangeService service) public static new Task Bind( ExchangeService service, ItemId id, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { - return service.BindToItem(id, propertySet); + return service.BindToItem(id, propertySet, token); } /// diff --git a/Core/ServiceObjects/Items/PostItem.cs b/Core/ServiceObjects/Items/PostItem.cs index 69a5259a..60cf1cc6 100644 --- a/Core/ServiceObjects/Items/PostItem.cs +++ b/Core/ServiceObjects/Items/PostItem.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -66,9 +67,10 @@ internal PostItem(ItemAttachment parentAttachment) public static new Task Bind( ExchangeService service, ItemId id, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { - return service.BindToItem(id, propertySet); + return service.BindToItem(id, propertySet, token); } /// diff --git a/Core/ServiceObjects/Items/Task.cs b/Core/ServiceObjects/Items/Task.cs index f388ad04..cb1b5563 100644 --- a/Core/ServiceObjects/Items/Task.cs +++ b/Core/ServiceObjects/Items/Task.cs @@ -29,6 +29,7 @@ namespace Microsoft.Exchange.WebServices.Data using System.Collections.Generic; using System.Globalization; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -67,9 +68,10 @@ internal Task(ItemAttachment parentAttachment) public static new Task Bind( ExchangeService service, ItemId id, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { - return service.BindToItem(id, propertySet); + return service.BindToItem(id, propertySet, token); } /// @@ -124,12 +126,13 @@ internal override bool GetIsTimeZoneHeaderRequired(bool isUpdateOperation) /// values of the task. Calling this method results in a call to EWS. /// /// The deletion mode. - public Task> DeleteCurrentOccurrence(DeleteMode deleteMode) + public Task> DeleteCurrentOccurrence(DeleteMode deleteMode, CancellationToken token = default(CancellationToken)) { return this.InternalDelete( deleteMode, null, - AffectedTaskOccurrence.SpecifiedOccurrenceOnly); + AffectedTaskOccurrence.SpecifiedOccurrenceOnly, + token); } /// @@ -142,13 +145,14 @@ public Task> DeleteCurrentOccurrence( /// a Task object representing the current occurrence if the task is recurring and the uypdate changed its recurrence /// pattern; or null in every other case. /// - public new async Task Update(ConflictResolutionMode conflictResolutionMode) + public new async Task Update(ConflictResolutionMode conflictResolutionMode, CancellationToken token = default(CancellationToken)) { return (Task)await this.InternalUpdate( null /* parentFolder */, conflictResolutionMode, MessageDisposition.SaveOnly, - null); + null, + token); } #region Properties diff --git a/Core/ServiceObjects/ResponseObjects/CalendarResponseMessageBase.cs b/Core/ServiceObjects/ResponseObjects/CalendarResponseMessageBase.cs index 01f37fca..c232d591 100644 --- a/Core/ServiceObjects/ResponseObjects/CalendarResponseMessageBase.cs +++ b/Core/ServiceObjects/ResponseObjects/CalendarResponseMessageBase.cs @@ -29,6 +29,7 @@ namespace Microsoft.Exchange.WebServices.Data using System.Collections.Generic; using System.ComponentModel; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -56,11 +57,11 @@ internal CalendarResponseMessageBase(Item referenceItem) /// A CalendarActionResults object containing the various items that were created or modified as a /// results of this operation. /// - public new async Task Save(FolderId destinationFolderId) + public new async Task Save(FolderId destinationFolderId, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId"); - return new CalendarActionResults(await this.InternalCreate(destinationFolderId, MessageDisposition.SaveOnly).ConfigureAwait(false)); + return new CalendarActionResults(await this.InternalCreate(destinationFolderId, MessageDisposition.SaveOnly, token).ConfigureAwait(false)); } /// @@ -71,9 +72,9 @@ internal CalendarResponseMessageBase(Item referenceItem) /// A CalendarActionResults object containing the various items that were created or modified as a /// results of this operation. /// - public new async Task Save(WellKnownFolderName destinationFolderName) + public new async Task Save(WellKnownFolderName destinationFolderName, CancellationToken token = default(CancellationToken)) { - return new CalendarActionResults(await this.InternalCreate(new FolderId(destinationFolderName), MessageDisposition.SaveOnly).ConfigureAwait(false)); + return new CalendarActionResults(await this.InternalCreate(new FolderId(destinationFolderName), MessageDisposition.SaveOnly, token).ConfigureAwait(false)); } /// @@ -83,9 +84,9 @@ internal CalendarResponseMessageBase(Item referenceItem) /// A CalendarActionResults object containing the various items that were created or modified as a /// results of this operation. /// - public new async Task Save() + public new async Task Save(CancellationToken token = default(CancellationToken)) { - return new CalendarActionResults(await this.InternalCreate(null, MessageDisposition.SaveOnly).ConfigureAwait(false)); + return new CalendarActionResults(await this.InternalCreate(null, MessageDisposition.SaveOnly, token).ConfigureAwait(false)); } /// @@ -95,9 +96,9 @@ internal CalendarResponseMessageBase(Item referenceItem) /// A CalendarActionResults object containing the various items that were created or modified as a /// results of this operation. /// - public new async Task Send() + public new async Task Send(CancellationToken token = default(CancellationToken)) { - return new CalendarActionResults(await this.InternalCreate(null, MessageDisposition.SendOnly).ConfigureAwait(false)); + return new CalendarActionResults(await this.InternalCreate(null, MessageDisposition.SendOnly, token).ConfigureAwait(false)); } /// @@ -108,11 +109,11 @@ internal CalendarResponseMessageBase(Item referenceItem) /// A CalendarActionResults object containing the various items that were created or modified as a /// results of this operation. /// - public new async Task SendAndSaveCopy(FolderId destinationFolderId) + public new async Task SendAndSaveCopy(FolderId destinationFolderId, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId"); - return new CalendarActionResults(await this.InternalCreate(destinationFolderId, MessageDisposition.SendAndSaveCopy).ConfigureAwait(false)); + return new CalendarActionResults(await this.InternalCreate(destinationFolderId, MessageDisposition.SendAndSaveCopy, token).ConfigureAwait(false)); } /// @@ -123,9 +124,9 @@ internal CalendarResponseMessageBase(Item referenceItem) /// A CalendarActionResults object containing the various items that were created or modified as a /// results of this operation. /// - public new async Task SendAndSaveCopy(WellKnownFolderName destinationFolderName) + public new async Task SendAndSaveCopy(WellKnownFolderName destinationFolderName, CancellationToken token = default(CancellationToken)) { - return new CalendarActionResults(await this.InternalCreate(new FolderId(destinationFolderName), MessageDisposition.SendAndSaveCopy).ConfigureAwait(false)); + return new CalendarActionResults(await this.InternalCreate(new FolderId(destinationFolderName), MessageDisposition.SendAndSaveCopy, token).ConfigureAwait(false)); } /// @@ -135,9 +136,9 @@ internal CalendarResponseMessageBase(Item referenceItem) /// A CalendarActionResults object containing the various items that were created or modified as a /// results of this operation. /// - public new async Task SendAndSaveCopy() + public new async Task SendAndSaveCopy(CancellationToken token = default(CancellationToken)) { - return new CalendarActionResults(await this.InternalCreate(null, MessageDisposition.SendAndSaveCopy).ConfigureAwait(false)); + return new CalendarActionResults(await this.InternalCreate(null, MessageDisposition.SendAndSaveCopy, token).ConfigureAwait(false)); } } } \ No newline at end of file diff --git a/Core/ServiceObjects/ResponseObjects/PostReply.cs b/Core/ServiceObjects/ResponseObjects/PostReply.cs index 8d00b950..3b98a177 100644 --- a/Core/ServiceObjects/ResponseObjects/PostReply.cs +++ b/Core/ServiceObjects/ResponseObjects/PostReply.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -79,14 +80,15 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// The parent folder id. /// The message disposition. /// Created PostItem. - internal async Task InternalCreate(FolderId parentFolderId, MessageDisposition? messageDisposition) + internal async Task InternalCreate(FolderId parentFolderId, MessageDisposition? messageDisposition, CancellationToken token) { ((ItemId)this.PropertyBag[ResponseObjectSchema.ReferenceItemId]).Assign(this.referenceItem.Id); List items = await this.Service.InternalCreateResponseObject( this, parentFolderId, - messageDisposition); + messageDisposition, + token); PostItem postItem = EwsUtilities.FindFirstItemOfType(items); @@ -103,7 +105,7 @@ internal async Task InternalCreate(FolderId parentFolderId, MessageDis /// Loads the specified set of properties on the object. /// /// The properties to load. - internal override Task> InternalLoad(PropertySet propertySet) + internal override Task> InternalLoad(PropertySet propertySet, CancellationToken token) { throw new InvalidOperationException(Strings.LoadingThisObjectTypeNotSupported); } @@ -117,7 +119,8 @@ internal override Task> InternalLoad( internal override Task> InternalDelete( DeleteMode deleteMode, SendCancellationsMode? sendCancellationsMode, - AffectedTaskOccurrence? affectedTaskOccurrences) + AffectedTaskOccurrence? affectedTaskOccurrences, + CancellationToken token) { throw new InvalidOperationException(Strings.DeletingThisObjectTypeNotAuthorized); } @@ -126,9 +129,9 @@ internal override Task> InternalDelet /// Saves the post reply in the same folder as the original post item. Calling this method results in a call to EWS. /// /// A PostItem representing the posted reply. - public async Task Save() + public async Task Save(CancellationToken token = default(CancellationToken)) { - return (PostItem)await this.InternalCreate(null, null).ConfigureAwait(false); + return (PostItem)await this.InternalCreate(null, null, token).ConfigureAwait(false); } /// @@ -136,11 +139,11 @@ public async Task Save() /// /// The Id of the folder in which to save the post reply. /// A PostItem representing the posted reply. - public async Task Save(FolderId destinationFolderId) + public async Task Save(FolderId destinationFolderId, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId"); - return (PostItem)await this.InternalCreate(destinationFolderId, null).ConfigureAwait(false); + return (PostItem)await this.InternalCreate(destinationFolderId, null, token).ConfigureAwait(false); } /// @@ -148,9 +151,9 @@ public async Task Save(FolderId destinationFolderId) /// /// The name of the folder in which to save the post reply. /// A PostItem representing the posted reply. - public async Task Save(WellKnownFolderName destinationFolderName) + public async Task Save(WellKnownFolderName destinationFolderName, CancellationToken token = default(CancellationToken)) { - return (PostItem)await this.InternalCreate(new FolderId(destinationFolderName), null).ConfigureAwait(false); + return (PostItem)await this.InternalCreate(new FolderId(destinationFolderName), null, token).ConfigureAwait(false); } #region Properties diff --git a/Core/ServiceObjects/ResponseObjects/RemoveFromCalendar.cs b/Core/ServiceObjects/ResponseObjects/RemoveFromCalendar.cs index eb514d7d..0a618694 100644 --- a/Core/ServiceObjects/ResponseObjects/RemoveFromCalendar.cs +++ b/Core/ServiceObjects/ResponseObjects/RemoveFromCalendar.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -77,7 +78,7 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Loads the specified set of properties on the object. /// /// The properties to load. - internal override Task> InternalLoad(PropertySet propertySet) + internal override Task> InternalLoad(PropertySet propertySet, CancellationToken token) { throw new NotSupportedException(); } @@ -91,7 +92,8 @@ internal override Task> InternalLoad( internal override Task> InternalDelete( DeleteMode deleteMode, SendCancellationsMode? sendCancellationsMode, - AffectedTaskOccurrence? affectedTaskOccurrences) + AffectedTaskOccurrence? affectedTaskOccurrences, + CancellationToken token) { throw new NotSupportedException(); } @@ -102,14 +104,15 @@ internal override Task> InternalDelet /// The parent folder id. /// The message disposition. /// A list of items that were created or modified as a results of this operation. - internal Task> InternalCreate(FolderId parentFolderId, MessageDisposition? messageDisposition) + internal Task> InternalCreate(FolderId parentFolderId, MessageDisposition? messageDisposition, CancellationToken token) { ((ItemId)this.PropertyBag[ResponseObjectSchema.ReferenceItemId]).Assign(this.referenceItem.Id); return this.Service.InternalCreateResponseObject( this, parentFolderId, - messageDisposition); + messageDisposition, + token); } } } \ No newline at end of file diff --git a/Core/ServiceObjects/ResponseObjects/ResponseObject.cs b/Core/ServiceObjects/ResponseObjects/ResponseObject.cs index 4ac87755..44d4ed2f 100644 --- a/Core/ServiceObjects/ResponseObjects/ResponseObject.cs +++ b/Core/ServiceObjects/ResponseObjects/ResponseObject.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.ComponentModel; + using System.Threading; using System.Threading.Tasks; /// @@ -70,7 +71,7 @@ internal override ServiceObjectSchema GetSchema() /// Loads the specified set of properties on the object. /// /// The properties to load. - internal override Task> InternalLoad(PropertySet propertySet) + internal override Task> InternalLoad(PropertySet propertySet, CancellationToken token) { throw new NotSupportedException(); } @@ -84,7 +85,8 @@ internal override Task> InternalLoad( internal override Task> InternalDelete( DeleteMode deleteMode, SendCancellationsMode? sendCancellationsMode, - AffectedTaskOccurrence? affectedTaskOccurrences) + AffectedTaskOccurrence? affectedTaskOccurrences, + CancellationToken token) { throw new NotSupportedException(); } @@ -95,14 +97,15 @@ internal override Task> InternalDelet /// The destination folder id. /// The message disposition. /// The list of items returned by EWS. - internal Task> InternalCreate(FolderId destinationFolderId, MessageDisposition messageDisposition) + internal Task> InternalCreate(FolderId destinationFolderId, MessageDisposition messageDisposition, CancellationToken token) { ((ItemId)this.PropertyBag[ResponseObjectSchema.ReferenceItemId]).Assign(this.referenceItem.Id); return this.Service.InternalCreateResponseObject( this, destinationFolderId, - messageDisposition); + messageDisposition, + token); } /// @@ -110,11 +113,11 @@ internal Task> InternalCreate(FolderId destinationFolderId, MessageDi /// /// The Id of the folder in which to save the response. /// A TMessage that represents the response. - public async Task Save(FolderId destinationFolderId) + public async Task Save(FolderId destinationFolderId, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId"); - return (await this.InternalCreate(destinationFolderId, MessageDisposition.SaveOnly).ConfigureAwait(false))[0] as TMessage; + return (await this.InternalCreate(destinationFolderId, MessageDisposition.SaveOnly, token).ConfigureAwait(false))[0] as TMessage; } /// @@ -122,56 +125,57 @@ public async Task Save(FolderId destinationFolderId) /// /// The name of the folder in which to save the response. /// A TMessage that represents the response. - public async Task Save(WellKnownFolderName destinationFolderName) + public async Task Save(WellKnownFolderName destinationFolderName, CancellationToken token = default(CancellationToken)) { - return (await this.InternalCreate(new FolderId(destinationFolderName), MessageDisposition.SaveOnly).ConfigureAwait(false))[0] as TMessage; + return (await this.InternalCreate(new FolderId(destinationFolderName), MessageDisposition.SaveOnly, token).ConfigureAwait(false))[0] as TMessage; } /// /// Saves the response in the Drafts folder. Calling this method results in a call to EWS. /// /// A TMessage that represents the response. - public async Task Save() + public async Task Save(CancellationToken token = default(CancellationToken)) { - return (await this.InternalCreate(null, MessageDisposition.SaveOnly).ConfigureAwait(false))[0] as TMessage; + return (await this.InternalCreate(null, MessageDisposition.SaveOnly, token).ConfigureAwait(false))[0] as TMessage; } /// /// Sends this response without saving a copy. Calling this method results in a call to EWS. /// - public System.Threading.Tasks.Task Send() + public System.Threading.Tasks.Task Send(CancellationToken token = default(CancellationToken)) { - return this.InternalCreate(null, MessageDisposition.SendOnly); + return this.InternalCreate(null, MessageDisposition.SendOnly, token); } /// /// Sends this response and saves a copy in the specified folder. Calling this method results in a call to EWS. /// /// The Id of the folder in which to save the copy of the message. - public System.Threading.Tasks.Task SendAndSaveCopy(FolderId destinationFolderId) + public System.Threading.Tasks.Task SendAndSaveCopy(FolderId destinationFolderId, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId"); - return this.InternalCreate(destinationFolderId, MessageDisposition.SendAndSaveCopy); + return this.InternalCreate(destinationFolderId, MessageDisposition.SendAndSaveCopy, token); } /// /// Sends this response and saves a copy in the specified folder. Calling this method results in a call to EWS. /// /// The name of the folder in which to save the copy of the message. - public System.Threading.Tasks.Task SendAndSaveCopy(WellKnownFolderName destinationFolderName) + public System.Threading.Tasks.Task SendAndSaveCopy(WellKnownFolderName destinationFolderName, CancellationToken token = default(CancellationToken)) { - return this.InternalCreate(new FolderId(destinationFolderName), MessageDisposition.SendAndSaveCopy); + return this.InternalCreate(new FolderId(destinationFolderName), MessageDisposition.SendAndSaveCopy, token); } /// /// Sends this response and saves a copy in the Sent Items folder. Calling this method results in a call to EWS. /// - public System.Threading.Tasks.Task SendAndSaveCopy() + public System.Threading.Tasks.Task SendAndSaveCopy(CancellationToken token = default(CancellationToken)) { return this.InternalCreate( null, - MessageDisposition.SendAndSaveCopy); + MessageDisposition.SendAndSaveCopy, + token); } #region Properties diff --git a/Core/ServiceObjects/ResponseObjects/SuppressReadReceipt.cs b/Core/ServiceObjects/ResponseObjects/SuppressReadReceipt.cs index f609f376..273d810b 100644 --- a/Core/ServiceObjects/ResponseObjects/SuppressReadReceipt.cs +++ b/Core/ServiceObjects/ResponseObjects/SuppressReadReceipt.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -77,7 +78,7 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Loads the specified set of properties on the object. /// /// The properties to load. - internal override Task> InternalLoad(PropertySet propertySet) + internal override Task> InternalLoad(PropertySet propertySet, CancellationToken token) { throw new NotSupportedException(); } @@ -91,7 +92,8 @@ internal override Task> InternalLoad( internal override Task> InternalDelete( DeleteMode deleteMode, SendCancellationsMode? sendCancellationsMode, - AffectedTaskOccurrence? affectedTaskOccurrences) + AffectedTaskOccurrence? affectedTaskOccurrences, + CancellationToken token) { throw new NotSupportedException(); } @@ -101,14 +103,15 @@ internal override Task> InternalDelet /// /// The parent folder id. /// The message disposition. - internal System.Threading.Tasks.Task InternalCreate(FolderId parentFolderId, MessageDisposition? messageDisposition) + internal System.Threading.Tasks.Task InternalCreate(FolderId parentFolderId, MessageDisposition? messageDisposition, CancellationToken token) { ((ItemId)this.PropertyBag[ResponseObjectSchema.ReferenceItemId]).Assign(this.referenceItem.Id); return this.Service.InternalCreateResponseObject( this, parentFolderId, - messageDisposition); + messageDisposition, + token); } } } \ No newline at end of file diff --git a/Core/ServiceObjects/ServiceObject.cs b/Core/ServiceObjects/ServiceObject.cs index 06a90aa1..3cb1407b 100644 --- a/Core/ServiceObjects/ServiceObject.cs +++ b/Core/ServiceObjects/ServiceObject.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.ObjectModel; using System.Reflection; + using System.Threading; using System.Threading.Tasks; /// @@ -290,7 +291,7 @@ internal void WriteToXmlForUpdate(EwsServiceXmlWriter writer) /// Loads the specified set of properties on the object. /// /// The properties to load. - internal abstract Task> InternalLoad(PropertySet propertySet); + internal abstract Task> InternalLoad(PropertySet propertySet, CancellationToken token); /// /// Deletes the object. @@ -301,23 +302,24 @@ internal void WriteToXmlForUpdate(EwsServiceXmlWriter writer) internal abstract Task> InternalDelete( DeleteMode deleteMode, SendCancellationsMode? sendCancellationsMode, - AffectedTaskOccurrence? affectedTaskOccurrences); + AffectedTaskOccurrence? affectedTaskOccurrences, + CancellationToken token); /// /// Loads the specified set of properties. Calling this method results in a call to EWS. /// /// The properties to load. - public Task> Load(PropertySet propertySet) + public Task> Load(PropertySet propertySet, CancellationToken token = default(CancellationToken)) { - return this.InternalLoad(propertySet); + return this.InternalLoad(propertySet, token); } /// /// Loads the first class properties. Calling this method results in a call to EWS. /// - public Task> Load() + public Task> Load(CancellationToken token = default(CancellationToken)) { - return this.InternalLoad(PropertySet.FirstClassProperties); + return this.InternalLoad(PropertySet.FirstClassProperties, token); } /// diff --git a/Groups/Requests/GetUnifiedGroupUnseenCountRequest.cs b/Groups/Requests/GetUnifiedGroupUnseenCountRequest.cs index 2a7ff290..0e72bc12 100644 --- a/Groups/Requests/GetUnifiedGroupUnseenCountRequest.cs +++ b/Groups/Requests/GetUnifiedGroupUnseenCountRequest.cs @@ -29,6 +29,7 @@ namespace Microsoft.Exchange.WebServices.Data.Groups using System.Collections.Generic; using System.Linq; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -124,9 +125,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - return (GetUnifiedGroupUnseenCountResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + return (GetUnifiedGroupUnseenCountResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); } } } \ No newline at end of file diff --git a/Groups/Requests/GetUserUnifiedGroupsRequest.cs b/Groups/Requests/GetUserUnifiedGroupsRequest.cs index 68600bd0..2c897054 100644 --- a/Groups/Requests/GetUserUnifiedGroupsRequest.cs +++ b/Groups/Requests/GetUserUnifiedGroupsRequest.cs @@ -30,6 +30,7 @@ namespace Microsoft.Exchange.WebServices.Data.Groups using System.Text; using Microsoft.Exchange.WebServices.Data.Groups; using System.Threading.Tasks; + using System.Threading; /// /// Represents a request to a GetUserUnifiedGroupsRequest operation @@ -118,9 +119,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - return (GetUserUnifiedGroupsResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + return (GetUserUnifiedGroupsResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); } } } \ No newline at end of file diff --git a/Groups/Requests/SetUnifiedGroupLastVisitedTimeRequest.cs b/Groups/Requests/SetUnifiedGroupLastVisitedTimeRequest.cs index f83761df..84099475 100644 --- a/Groups/Requests/SetUnifiedGroupLastVisitedTimeRequest.cs +++ b/Groups/Requests/SetUnifiedGroupLastVisitedTimeRequest.cs @@ -29,6 +29,7 @@ namespace Microsoft.Exchange.WebServices.Data.Groups using System.Collections.Generic; using System.Linq; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -125,9 +126,9 @@ internal override ExchangeVersion GetMinimumRequiredServerVersion() /// Executes this request. /// /// Service response. - internal async Task Execute() + internal async Task Execute(CancellationToken token) { - return (ServiceResponse)await this.InternalExecuteAsync().ConfigureAwait(false); + return (ServiceResponse)await this.InternalExecuteAsync(token).ConfigureAwait(false); } } } \ No newline at end of file diff --git a/Interfaces/IEwsHttpWebRequest.cs b/Interfaces/IEwsHttpWebRequest.cs index 454be06f..64719dd9 100644 --- a/Interfaces/IEwsHttpWebRequest.cs +++ b/Interfaces/IEwsHttpWebRequest.cs @@ -30,6 +30,7 @@ namespace Microsoft.Exchange.WebServices.Data using System.Net; using System.Net.Http.Headers; using System.Security.Cryptography.X509Certificates; + using System.Threading; using System.Threading.Tasks; /// @@ -59,7 +60,7 @@ string Content /// /// A that contains the response from the Internet resource. /// - Task GetResponse(); + Task GetResponse(CancellationToken token); /// /// Gets or sets the value of the Accept HTTP header. diff --git a/Microsoft.Exchange.WebServices.NETStandard.csproj b/Microsoft.Exchange.WebServices.NETStandard.csproj index 0c15e4c3..dc8c618f 100644 --- a/Microsoft.Exchange.WebServices.NETStandard.csproj +++ b/Microsoft.Exchange.WebServices.NETStandard.csproj @@ -22,7 +22,10 @@ The Exchange Web Services (EWS) Managed API provides a managed interface for developing .NET client applications that use EWS. By using the EWS Managed API, you can access almost all the information stored in an Office 365, Exchange Online, or Exchange Server mailbox. removed obsolete WebRequests and switched to HttpClient internally fixed issue with file attachements downloads -restored ldap autodiscover functionality +restored ldap autodiscover functionality +merged changes from official Microsoft repository +added cancellation token for most of methods + diff --git a/Misc/UserConfiguration.cs b/Misc/UserConfiguration.cs index 77942717..fd755ea4 100644 --- a/Misc/UserConfiguration.cs +++ b/Misc/UserConfiguration.cs @@ -29,6 +29,7 @@ namespace Microsoft.Exchange.WebServices.Data using System.Collections.Generic; using System.IO; using System.Text; + using System.Threading; using System.Threading.Tasks; using System.Xml; @@ -264,12 +265,14 @@ public static async Task Bind( ExchangeService service, string name, FolderId parentFolderId, - UserConfigurationProperties properties) + UserConfigurationProperties properties, + CancellationToken token = default(CancellationToken)) { UserConfiguration result = await service.GetUserConfiguration( name, parentFolderId, - properties); + properties, + token); result.isNew = false; @@ -303,7 +306,7 @@ public static Task Bind( /// /// The name of the user configuration. /// The Id of the folder in which to save the user configuration. - public async System.Threading.Tasks.Task Save(string name, FolderId parentFolderId) + public async System.Threading.Tasks.Task Save(string name, FolderId parentFolderId, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(name, "name"); EwsUtilities.ValidateParam(parentFolderId, "parentFolderId"); @@ -318,7 +321,7 @@ public async System.Threading.Tasks.Task Save(string name, FolderId parentFolder this.parentFolderId = parentFolderId; this.name = name; - await this.service.CreateUserConfiguration(this); + await this.service.CreateUserConfiguration(this, token); this.isNew = false; @@ -339,7 +342,7 @@ public System.Threading.Tasks.Task Save(string name, WellKnownFolderName parentF /// Updates the user configuration by applying local changes to the Exchange server. /// Calling this method results in a call to EWS. /// - public async System.Threading.Tasks.Task Update() + public async System.Threading.Tasks.Task Update(CancellationToken token = default(CancellationToken)) { if (this.isNew) { @@ -350,7 +353,7 @@ public async System.Threading.Tasks.Task Update() this.IsPropertyUpdated(UserConfigurationProperties.Dictionary) || this.IsPropertyUpdated(UserConfigurationProperties.XmlData)) { - await this.service.UpdateUserConfiguration(this); + await this.service.UpdateUserConfiguration(this, token); } this.ResetIsDirty(); @@ -359,7 +362,7 @@ public async System.Threading.Tasks.Task Update() /// /// Deletes the user configuration. Calling this method results in a call to EWS. /// - public async System.Threading.Tasks.Task Delete() + public async System.Threading.Tasks.Task Delete(CancellationToken token = default(CancellationToken)) { if (this.isNew) { @@ -367,7 +370,7 @@ public async System.Threading.Tasks.Task Delete() } else { - await this.service.DeleteUserConfiguration(this.name, this.parentFolderId); + await this.service.DeleteUserConfiguration(this.name, this.parentFolderId, token); } } @@ -375,11 +378,11 @@ public async System.Threading.Tasks.Task Delete() /// Loads the specified properties on the user configuration. Calling this method results in a call to EWS. /// /// The properties to load. - public System.Threading.Tasks.Task Load(UserConfigurationProperties properties) + public System.Threading.Tasks.Task Load(UserConfigurationProperties properties, CancellationToken token = default(CancellationToken)) { this.InitializeProperties(properties); - return this.service.LoadPropertiesForUserConfiguration(this, properties); + return this.service.LoadPropertiesForUserConfiguration(this, properties, token); } /// diff --git a/Notifications/PullSubscription.cs b/Notifications/PullSubscription.cs index 47190f1c..21a0553d 100644 --- a/Notifications/PullSubscription.cs +++ b/Notifications/PullSubscription.cs @@ -26,6 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; + using System.Threading; using System.Threading.Tasks; /// @@ -49,9 +50,9 @@ internal PullSubscription(ExchangeService service) /// in time defined by the Watermark property. When GetEvents succeeds, Watermark is updated. /// /// Returns a collection of events that occurred since the last watermark. - public async Task GetEvents() + public async Task GetEvents(CancellationToken token = default(CancellationToken)) { - GetEventsResults results = await this.Service.GetEvents(this.Id, this.Watermark); + GetEventsResults results = await this.Service.GetEvents(this.Id, this.Watermark, token); this.Watermark = results.NewWatermark; this.moreEventsAvailable = results.MoreEventsAvailable; @@ -62,9 +63,9 @@ public async Task GetEvents() /// /// Unsubscribes from the pull subscription. /// - public System.Threading.Tasks.Task Unsubscribe() + public System.Threading.Tasks.Task Unsubscribe(CancellationToken token = default(CancellationToken)) { - return this.Service.Unsubscribe(this.Id); + return this.Service.Unsubscribe(this.Id, token); } /// diff --git a/Notifications/StreamingSubscription.cs b/Notifications/StreamingSubscription.cs index e1208796..31096f8e 100644 --- a/Notifications/StreamingSubscription.cs +++ b/Notifications/StreamingSubscription.cs @@ -26,6 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; + using System.Threading; /// /// Represents a streaming subscription. @@ -55,9 +56,9 @@ public StreamingSubscription(ExchangeService service, string subscriptionId) /// /// Unsubscribes from the streaming subscription. /// - public System.Threading.Tasks.Task Unsubscribe() + public System.Threading.Tasks.Task Unsubscribe(CancellationToken token = default(CancellationToken)) { - return this.Service.Unsubscribe(this.Id); + return this.Service.Unsubscribe(this.Id, token); } /// diff --git a/Notifications/StreamingSubscriptionConnection.cs b/Notifications/StreamingSubscriptionConnection.cs index fdef52fb..016ba737 100644 --- a/Notifications/StreamingSubscriptionConnection.cs +++ b/Notifications/StreamingSubscriptionConnection.cs @@ -27,6 +27,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; using System.Collections.Generic; + using System.Threading; /// /// Represents a connection to an ongoing stream of events. @@ -202,7 +203,7 @@ public void RemoveSubscription(StreamingSubscription subscription) /// This results in a long-standing call to EWS. /// /// Thrown when Open is called while connected. - public void Open() + public void Open(CancellationToken token = default(CancellationToken)) { lock (this.lockObject) { @@ -223,7 +224,7 @@ public void Open() this.currentHangingRequest.OnDisconnect += new HangingServiceRequestBase.HangingRequestDisconnectHandler(this.OnRequestDisconnect); - this.currentHangingRequest.InternalExecute(); + this.currentHangingRequest.InternalExecute(token); } } diff --git a/UnifiedMessaging/PhoneCall.cs b/UnifiedMessaging/PhoneCall.cs index 5ea656f2..6b51d1e5 100644 --- a/UnifiedMessaging/PhoneCall.cs +++ b/UnifiedMessaging/PhoneCall.cs @@ -27,6 +27,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; using System.Text; + using System.Threading; /// /// Represents a phone call. @@ -75,9 +76,9 @@ internal PhoneCall(ExchangeService service, PhoneCallId id) /// /// Refreshes the state of this phone call. /// - public async System.Threading.Tasks.Task Refresh() + public async System.Threading.Tasks.Task Refresh(CancellationToken token = default(CancellationToken)) { - PhoneCall phoneCall = await service.UnifiedMessaging.GetPhoneCallInformation(this.id).ConfigureAwait(false); + PhoneCall phoneCall = await service.UnifiedMessaging.GetPhoneCallInformation(this.id, token).ConfigureAwait(false); this.state = phoneCall.State; this.connectionFailureCause = phoneCall.ConnectionFailureCause; this.sipResponseText = phoneCall.SIPResponseText; @@ -87,7 +88,7 @@ public async System.Threading.Tasks.Task Refresh() /// /// Disconnects this phone call. /// - public void Disconnect() + public async System.Threading.Tasks.Task Disconnect(CancellationToken token = default(CancellationToken)) { // If call is already disconnected, throw exception // @@ -96,7 +97,7 @@ public void Disconnect() throw new ServiceLocalException(Strings.PhoneCallAlreadyDisconnected); } - this.service.UnifiedMessaging.DisconnectPhoneCall(this.id); + await this.service.UnifiedMessaging.DisconnectPhoneCall(this.id, token); this.state = PhoneCallState.Disconnected; } diff --git a/UnifiedMessaging/UnifiedMessaging.cs b/UnifiedMessaging/UnifiedMessaging.cs index 14858d34..df0af4a0 100644 --- a/UnifiedMessaging/UnifiedMessaging.cs +++ b/UnifiedMessaging/UnifiedMessaging.cs @@ -28,6 +28,7 @@ namespace Microsoft.Exchange.WebServices.Data using System; using System.Collections.Generic; using System.Text; + using System.Threading; using System.Threading.Tasks; /// @@ -52,7 +53,7 @@ internal UnifiedMessaging(ExchangeService service) /// The Id of the message to read. /// The full dial string used to call the phone. /// An object providing status for the phone call. - public async Task PlayOnPhone(ItemId itemId, string dialString) + public async Task PlayOnPhone(ItemId itemId, string dialString, CancellationToken token = default(CancellationToken)) { EwsUtilities.ValidateParam(itemId, "itemId"); EwsUtilities.ValidateParam(dialString, "dialString"); @@ -60,7 +61,7 @@ public async Task PlayOnPhone(ItemId itemId, string dialString) PlayOnPhoneRequest request = new PlayOnPhoneRequest(service); request.DialString = dialString; request.ItemId = itemId; - PlayOnPhoneResponse serviceResponse = await request.Execute().ConfigureAwait(false); + PlayOnPhoneResponse serviceResponse = await request.Execute(token).ConfigureAwait(false); PhoneCall callInformation = new PhoneCall(service, serviceResponse.PhoneCallId); @@ -72,11 +73,11 @@ public async Task PlayOnPhone(ItemId itemId, string dialString) /// /// The Id of the phone call. /// An object providing status for the phone call. - internal async Task GetPhoneCallInformation(PhoneCallId id) + internal async Task GetPhoneCallInformation(PhoneCallId id, CancellationToken token) { GetPhoneCallRequest request = new GetPhoneCallRequest(service); request.Id = id; - GetPhoneCallResponse response = await request.Execute().ConfigureAwait(false); + GetPhoneCallResponse response = await request.Execute(token).ConfigureAwait(false); return response.PhoneCall; } @@ -85,11 +86,11 @@ internal async Task GetPhoneCallInformation(PhoneCallId id) /// Disconnects a phone call. /// /// The Id of the phone call. - internal System.Threading.Tasks.Task DisconnectPhoneCall(PhoneCallId id) + internal System.Threading.Tasks.Task DisconnectPhoneCall(PhoneCallId id, CancellationToken token) { DisconnectPhoneCallRequest request = new DisconnectPhoneCallRequest(service); request.Id = id; - return request.Execute(); + return request.Execute(token); } } } \ No newline at end of file From 81a33de5ed52d2c5c82867016410343fd70664ff Mon Sep 17 00:00:00 2001 From: sherlock1982 Date: Sun, 2 Sep 2018 16:28:09 +0300 Subject: [PATCH 13/19] more missing token support --- Core/ServiceObjects/Folders/CalendarFolder.cs | 16 ++++++++++------ Core/ServiceObjects/Folders/ContactsFolder.cs | 16 ++++++++++------ Core/ServiceObjects/Folders/Folder.cs | 16 ++++++++++------ Core/ServiceObjects/Folders/SearchFolder.cs | 16 ++++++++++------ Core/ServiceObjects/Folders/TasksFolder.cs | 16 ++++++++++------ 5 files changed, 50 insertions(+), 30 deletions(-) diff --git a/Core/ServiceObjects/Folders/CalendarFolder.cs b/Core/ServiceObjects/Folders/CalendarFolder.cs index 3134fbdd..d8ab237f 100644 --- a/Core/ServiceObjects/Folders/CalendarFolder.cs +++ b/Core/ServiceObjects/Folders/CalendarFolder.cs @@ -61,12 +61,13 @@ public class CalendarFolder : Folder /// The service to use to bind to the calendar folder. /// The Id of the calendar folder to bind to. /// A CalendarFolder instance representing the calendar folder corresponding to the specified Id. - public static new Task Bind(ExchangeService service, FolderId id) + public static new Task Bind(ExchangeService service, FolderId id, CancellationToken token = default(CancellationToken)) { return CalendarFolder.Bind( service, id, - PropertySet.FirstClassProperties); + PropertySet.FirstClassProperties, + token); } /// @@ -80,12 +81,14 @@ public class CalendarFolder : Folder public static new Task Bind( ExchangeService service, WellKnownFolderName name, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { return CalendarFolder.Bind( service, new FolderId(name), - propertySet); + propertySet, + token); } /// @@ -95,12 +98,13 @@ public class CalendarFolder : Folder /// The service to use to bind to the calendar folder. /// The name of the calendar folder to bind to. /// A CalendarFolder instance representing the calendar folder with the specified name. - public static new Task Bind(ExchangeService service, WellKnownFolderName name) + public static new Task Bind(ExchangeService service, WellKnownFolderName name, CancellationToken token = default(CancellationToken)) { return CalendarFolder.Bind( service, new FolderId(name), - PropertySet.FirstClassProperties); + PropertySet.FirstClassProperties, + token); } /// diff --git a/Core/ServiceObjects/Folders/ContactsFolder.cs b/Core/ServiceObjects/Folders/ContactsFolder.cs index 9fb491c6..913de76a 100644 --- a/Core/ServiceObjects/Folders/ContactsFolder.cs +++ b/Core/ServiceObjects/Folders/ContactsFolder.cs @@ -68,12 +68,13 @@ public ContactsFolder(ExchangeService service) /// The service to use to bind to the contacts folder. /// The Id of the contacts folder to bind to. /// A ContactsFolder instance representing the contacts folder corresponding to the specified Id. - public static new Task Bind(ExchangeService service, FolderId id) + public static new Task Bind(ExchangeService service, FolderId id, CancellationToken token = default(CancellationToken)) { return ContactsFolder.Bind( service, id, - PropertySet.FirstClassProperties); + PropertySet.FirstClassProperties, + token); } /// @@ -86,12 +87,14 @@ public ContactsFolder(ExchangeService service) public static new Task Bind( ExchangeService service, WellKnownFolderName name, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { return ContactsFolder.Bind( service, new FolderId(name), - propertySet); + propertySet, + token); } /// @@ -100,12 +103,13 @@ public ContactsFolder(ExchangeService service) /// The service to use to bind to the contacts folder. /// The name of the contacts folder to bind to. /// A ContactsFolder instance representing the contacts folder with the specified name. - public static new Task Bind(ExchangeService service, WellKnownFolderName name) + public static new Task Bind(ExchangeService service, WellKnownFolderName name, CancellationToken token = default(CancellationToken)) { return ContactsFolder.Bind( service, new FolderId(name), - PropertySet.FirstClassProperties); + PropertySet.FirstClassProperties, + token); } /// diff --git a/Core/ServiceObjects/Folders/Folder.cs b/Core/ServiceObjects/Folders/Folder.cs index cb56f720..5826802b 100644 --- a/Core/ServiceObjects/Folders/Folder.cs +++ b/Core/ServiceObjects/Folders/Folder.cs @@ -68,12 +68,13 @@ public static Task Bind( /// The service to use to bind to the folder. /// The Id of the folder to bind to. /// A Folder instance representing the folder corresponding to the specified Id. - public static Task Bind(ExchangeService service, FolderId id) + public static Task Bind(ExchangeService service, FolderId id, CancellationToken token = default(CancellationToken)) { return Folder.Bind( service, id, - PropertySet.FirstClassProperties); + PropertySet.FirstClassProperties, + token); } /// @@ -87,12 +88,14 @@ public static Task Bind(ExchangeService service, FolderId id) public static Task Bind( ExchangeService service, WellKnownFolderName name, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { return Folder.Bind( service, new FolderId(name), - propertySet); + propertySet, + token); } /// @@ -102,12 +105,13 @@ public static Task Bind( /// The service to use to bind to the folder. /// The name of the folder to bind to. /// A Folder instance representing the folder with the specified name. - public static Task Bind(ExchangeService service, WellKnownFolderName name) + public static Task Bind(ExchangeService service, WellKnownFolderName name, CancellationToken token = default(CancellationToken)) { return Folder.Bind( service, new FolderId(name), - PropertySet.FirstClassProperties); + PropertySet.FirstClassProperties, + token); } /// diff --git a/Core/ServiceObjects/Folders/SearchFolder.cs b/Core/ServiceObjects/Folders/SearchFolder.cs index d550a0a7..bcff2497 100644 --- a/Core/ServiceObjects/Folders/SearchFolder.cs +++ b/Core/ServiceObjects/Folders/SearchFolder.cs @@ -61,12 +61,13 @@ public class SearchFolder : Folder /// The service to use to bind to the search folder. /// The Id of the search folder to bind to. /// A SearchFolder instance representing the search folder corresponding to the specified Id. - public static new Task Bind(ExchangeService service, FolderId id) + public static new Task Bind(ExchangeService service, FolderId id, CancellationToken token = default(CancellationToken)) { return SearchFolder.Bind( service, id, - PropertySet.FirstClassProperties); + PropertySet.FirstClassProperties, + token); } /// @@ -80,12 +81,14 @@ public class SearchFolder : Folder public static new Task Bind( ExchangeService service, WellKnownFolderName name, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { return SearchFolder.Bind( service, new FolderId(name), - propertySet); + propertySet, + token); } /// @@ -95,12 +98,13 @@ public class SearchFolder : Folder /// The service to use to bind to the search folder. /// The name of the search folder to bind to. /// A SearchFolder instance representing the search folder with the specified name. - public static new Task Bind(ExchangeService service, WellKnownFolderName name) + public static new Task Bind(ExchangeService service, WellKnownFolderName name, CancellationToken token = default(CancellationToken)) { return SearchFolder.Bind( service, new FolderId(name), - PropertySet.FirstClassProperties); + PropertySet.FirstClassProperties, + token); } /// diff --git a/Core/ServiceObjects/Folders/TasksFolder.cs b/Core/ServiceObjects/Folders/TasksFolder.cs index 4047224f..7da5b2c3 100644 --- a/Core/ServiceObjects/Folders/TasksFolder.cs +++ b/Core/ServiceObjects/Folders/TasksFolder.cs @@ -70,12 +70,13 @@ public TasksFolder(ExchangeService service) /// The service to use to bind to the tasks folder. /// The Id of the tasks folder to bind to. /// A TasksFolder instance representing the task folder corresponding to the specified Id. - public static new Task Bind(ExchangeService service, FolderId id) + public static new Task Bind(ExchangeService service, FolderId id, CancellationToken token = default(CancellationToken)) { return TasksFolder.Bind( service, id, - PropertySet.FirstClassProperties); + PropertySet.FirstClassProperties, + token); } /// @@ -89,12 +90,14 @@ public TasksFolder(ExchangeService service) public static new Task Bind( ExchangeService service, WellKnownFolderName name, - PropertySet propertySet) + PropertySet propertySet, + CancellationToken token = default(CancellationToken)) { return TasksFolder.Bind( service, new FolderId(name), - propertySet); + propertySet, + token); } /// @@ -104,12 +107,13 @@ public TasksFolder(ExchangeService service) /// The service to use to bind to the tasks folder. /// The name of the tasks folder to bind to. /// A TasksFolder instance representing the tasks folder with the specified name. - public static new Task Bind(ExchangeService service, WellKnownFolderName name) + public static new Task Bind(ExchangeService service, WellKnownFolderName name, CancellationToken token = default(CancellationToken)) { return TasksFolder.Bind( service, new FolderId(name), - PropertySet.FirstClassProperties); + PropertySet.FirstClassProperties, + token); } /// From 9c068f18a91a7d9dff1038ca11fd8f91ff1903f1 Mon Sep 17 00:00:00 2001 From: Annosz Date: Mon, 11 May 2020 13:26:45 +0200 Subject: [PATCH 14/19] Handling empty Content-Encoding header --- Core/Requests/ServiceRequestBase.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Core/Requests/ServiceRequestBase.cs b/Core/Requests/ServiceRequestBase.cs index e411fe41..40c1cff8 100644 --- a/Core/Requests/ServiceRequestBase.cs +++ b/Core/Requests/ServiceRequestBase.cs @@ -112,6 +112,11 @@ protected static async Task GetResponseStream(IEwsHttpWebResponse respon private static Stream WrapStream(Stream responseStream, string contentEncoding) { + if (string.IsNullOrEmpty(contentEncoding)) + { + return responseStream; + } + if (contentEncoding.ToLowerInvariant().Contains("gzip")) { return new GZipStream(responseStream, CompressionMode.Decompress); From 68122e698a663a63952d492cf0ca0a8c1f069db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orkun=20Ak=C3=A7a?= Date: Fri, 20 Nov 2020 21:01:53 +0300 Subject: [PATCH 15/19] Fix of "Cannot process the message because the content type 'text/plain; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'" error. --- Core/EwsHttpWebRequest.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Core/EwsHttpWebRequest.cs b/Core/EwsHttpWebRequest.cs index 65a9c7b1..81bb560a 100644 --- a/Core/EwsHttpWebRequest.cs +++ b/Core/EwsHttpWebRequest.cs @@ -55,7 +55,8 @@ internal EwsHttpWebRequest(Uri uri) { Method = "GET"; RequestUri = uri; - _httpClientHandler = new HttpClientHandler() { + _httpClientHandler = new HttpClientHandler() + { AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip }; _httpClient = new HttpClient(_httpClientHandler); @@ -89,6 +90,8 @@ public async Task GetResponse(CancellationToken token) { var message = new HttpRequestMessage(new HttpMethod(Method), RequestUri); message.Content = new StringContent(Content); + message.Content.Headers.Clear(); + message.Content.Headers.Add("Content-Type", "text/xml; charset=utf-8"); //if (!string.IsNullOrEmpty(ContentType)) // message.Content.Headers.ContentType = new MediaTypeHeaderValue(ContentType); @@ -109,7 +112,7 @@ public async Task GetResponse(CancellationToken token) { response = await _httpClient.SendAsync(message, token); } - catch(Exception exception) + catch (Exception exception) { throw new EwsHttpClientException(exception); } From 23cce19028fba52ea6a4aa0d14bfb24665d9b3d5 Mon Sep 17 00:00:00 2001 From: Nikolai Orekhov Date: Fri, 29 Jan 2021 12:59:37 +0200 Subject: [PATCH 16/19] added license file, updated some dependencies --- Microsoft.Exchange.WebServices.NETStandard.csproj | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Microsoft.Exchange.WebServices.NETStandard.csproj b/Microsoft.Exchange.WebServices.NETStandard.csproj index dc8c618f..4cee8984 100644 --- a/Microsoft.Exchange.WebServices.NETStandard.csproj +++ b/Microsoft.Exchange.WebServices.NETStandard.csproj @@ -1,4 +1,4 @@ - + 2.0.0 @@ -26,6 +26,8 @@ restored ldap autodiscover functionality merged changes from official Microsoft repository added cancellation token for most of methods + 2.0.0-beta2 + license.txt @@ -37,7 +39,7 @@ added cancellation token for most of methods - 4.5.0 + 4.7.0 @@ -46,8 +48,15 @@ added cancellation token for most of methods - + + + + True + + + + From 084929a331dbc5fc0b9dea8c44df14c509d8553b Mon Sep 17 00:00:00 2001 From: StrictLine Date: Sun, 30 May 2021 14:23:55 +0200 Subject: [PATCH 17/19] Auto correct of VS for Mac --- ...ft.Exchange.WebServices.NETStandard.csproj | 97 +++++++++---------- 1 file changed, 48 insertions(+), 49 deletions(-) diff --git a/Microsoft.Exchange.WebServices.NETStandard.csproj b/Microsoft.Exchange.WebServices.NETStandard.csproj index 4cee8984..fa0c3779 100644 --- a/Microsoft.Exchange.WebServices.NETStandard.csproj +++ b/Microsoft.Exchange.WebServices.NETStandard.csproj @@ -1,62 +1,61 @@  - - 2.0.0 - netstandard2.0;net461 - Microsoft.Exchange.WebServices.NETStandard - Microsoft.Exchange.WebServices.NETStandard - false - false - false - false - false - false - false - true - sherlock1982 - https://github.com/sherlock1982/ews-managed-api - git - ews exchange office365 Microsoft Web API Email Client Library C# - https://github.com/sherlock1982/ews-managed-api - Microsoft.Exchange.WebServices.NETStandard - The Exchange Web Services (EWS) Managed API provides a managed interface for developing .NET client applications that use EWS. By using the EWS Managed API, you can access almost all the information stored in an Office 365, Exchange Online, or Exchange Server mailbox. - removed obsolete WebRequests and switched to HttpClient internally -fixed issue with file attachements downloads -restored ldap autodiscover functionality -merged changes from official Microsoft repository -added cancellation token for most of methods - - 2.0.0-beta2 - license.txt - - - - - - - + + 2.0.0 + netstandard2.0;net461 + Microsoft.Exchange.WebServices.NETStandard + Microsoft.Exchange.WebServices.NETStandard + false + false + false + false + false + false + false + true + sherlock1982 + https://github.com/sherlock1982/ews-managed-api + git + ews exchange office365 Microsoft Web API Email Client Library C# + https://github.com/sherlock1982/ews-managed-api + Microsoft.Exchange.WebServices.NETStandard + The Exchange Web Services (EWS) Managed API provides a managed interface for developing .NET client applications that use EWS. By using the EWS Managed API, you can access almost all the information stored in an Office 365, Exchange Online, or Exchange Server mailbox. + removed obsolete WebRequests and switched to HttpClient internally +fixed issue with file attachements downloads +restored ldap autodiscover functionality +merged changes from official Microsoft repository +added cancellation token for most of methods + + 2.0.0-beta2 + license.txt + + + + + + + - - - 4.7.0 - + + + - - + + - - - + + + - - - True - - + + + True + + From bf6b43d3c2cc251eddc8ac8373c3bb73aa9011cc Mon Sep 17 00:00:00 2001 From: StrictLine Date: Sun, 30 May 2021 14:27:41 +0200 Subject: [PATCH 18/19] Working implementation of Load(Stream stream) and Load(string fileName) --- ComplexProperties/FileAttachment.cs | 34 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/ComplexProperties/FileAttachment.cs b/ComplexProperties/FileAttachment.cs index ebf76341..cb3d726f 100644 --- a/ComplexProperties/FileAttachment.cs +++ b/ComplexProperties/FileAttachment.cs @@ -189,15 +189,17 @@ internal override void WriteElementsToXml(EwsServiceXmlWriter writer) /// The stream to load the content of the attachment into. public async System.Threading.Tasks.Task Load(Stream stream) { - this.loadToStream = stream; - + // TODO: content/contentStream should be removed or should reference to underlying value try { + // 1) Load attachment from EWS await this.Load(); + + // 2) Write content to stream + stream.Write(Content, 0, Content.Length); } finally { - this.loadToStream = null; } } @@ -207,21 +209,19 @@ public async System.Threading.Tasks.Task Load(Stream stream) /// The name of the file to load the content of the attachment into. If the file already exists, it is overwritten. public async System.Threading.Tasks.Task Load(string fileName) { - this.loadToStream = new FileStream(fileName, FileMode.Create); - - try - { - await this.Load(); - } - finally - { - this.loadToStream.Dispose(); - this.loadToStream = null; - } + using(var fileStream = new FileStream(fileName, FileMode.Create)) + try + { + // 1) Load attachment from EWS + await this.Load(); + + // 2) Write content to file + fileStream.Write(Content, 0, Content.Length); + } + finally + { + } - this.fileName = fileName; - this.content = null; - this.contentStream = null; } /// From 6f7e5ea2a386863983b86f0eb61e5c23582657c9 Mon Sep 17 00:00:00 2001 From: StrictLine Date: Sun, 30 May 2021 14:30:13 +0200 Subject: [PATCH 19/19] Update .gitignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 54cebc8e..92c27fa1 100644 --- a/.gitignore +++ b/.gitignore @@ -184,3 +184,8 @@ UpgradeLog*.htm FakesAssemblies/ /project.lock.json /.svn + +# VS for Mac +mono_crash.*.json +UserPrefs.xml +project-cache/ \ No newline at end of file