diff --git a/Exceptions/AccountIsLockedException.cs b/Exceptions/AccountIsLockedException.cs index eb343007..1717853c 100644 --- a/Exceptions/AccountIsLockedException.cs +++ b/Exceptions/AccountIsLockedException.cs @@ -23,35 +23,60 @@ * DEALINGS IN THE SOFTWARE. */ -namespace Microsoft.Exchange.WebServices.Data + namespace Microsoft.Exchange.WebServices.Data { - using System; + using System; + using System.Runtime.Serialization; - /// - /// Represents an error that occurs when the account that is being accessed is locked and requires user interaction to be unlocked. - /// - [Serializable] - public class AccountIsLockedException : ServiceRemoteException - { - /// - /// Initializes a new instance of the class. - /// - /// Error message text. - /// URL for client to visit to unlock account. - /// Inner exception. - public AccountIsLockedException(string message, Uri accountUnlockUrl, Exception innerException) - : base(message, innerException) - { - this.AccountUnlockUrl = accountUnlockUrl; - } + /// + /// Represents an error that occurs when the account that is being accessed is locked and requires user interaction to be unlocked. + /// + [Serializable] + public class AccountIsLockedException : ServiceRemoteException + { + /// + /// Initializes a new instance of the class. + /// + /// Error message text. + /// URL for client to visit to unlock account. + /// Inner exception. + public AccountIsLockedException(string message, Uri accountUnlockUrl, Exception innerException) + : base(message, innerException) + { + this.AccountUnlockUrl = accountUnlockUrl; + } - /// - /// Gets the URL of a web page where the user can navigate to unlock his or her account. - /// - public Uri AccountUnlockUrl - { - get; - private set; - } - } + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + protected AccountIsLockedException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + this.AccountUnlockUrl = (Uri)info.GetValue("AccountUnlockUrl", typeof(Uri)); + } + + /// Sets the object with the parameter name and additional exception information. + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + /// The object is a null reference (Nothing in Visual Basic). + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + EwsUtilities.Assert(info != null, "AccountIsLockedException.GetObjectData", "info is null"); + + base.GetObjectData(info, context); + + info.AddValue("AccountUnlockUrl", this.AccountUnlockUrl, typeof(Uri)); + } + + /// + /// Gets the URL of a web page where the user can navigate to unlock his or her account. + /// + public Uri AccountUnlockUrl + { + get; + private set; + } + } } \ No newline at end of file diff --git a/Exceptions/AutodiscoverLocalException.cs b/Exceptions/AutodiscoverLocalException.cs index 875041ba..b822528e 100644 --- a/Exceptions/AutodiscoverLocalException.cs +++ b/Exceptions/AutodiscoverLocalException.cs @@ -26,8 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; - using System.Collections.Generic; - using System.Text; + using System.Runtime.Serialization; /// /// Represents an exception that is thrown when the Autodiscover service could not be contacted. @@ -60,6 +59,16 @@ public AutodiscoverLocalException(string message) public AutodiscoverLocalException(string message, Exception innerException) : base(message, innerException) { - } - } + } + + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + protected AutodiscoverLocalException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } } \ No newline at end of file diff --git a/Exceptions/AutodiscoverRemoteException.cs b/Exceptions/AutodiscoverRemoteException.cs index bb9614f8..5c5e0fed 100644 --- a/Exceptions/AutodiscoverRemoteException.cs +++ b/Exceptions/AutodiscoverRemoteException.cs @@ -26,8 +26,7 @@ namespace Microsoft.Exchange.WebServices.Autodiscover { using System; - using System.Collections.Generic; - using System.Text; + using System.Runtime.Serialization; using Microsoft.Exchange.WebServices.Data; /// @@ -36,7 +35,7 @@ namespace Microsoft.Exchange.WebServices.Autodiscover [Serializable] public class AutodiscoverRemoteException : ServiceRemoteException { - private AutodiscoverError error; + private readonly AutodiscoverError error; /// /// Initializes a new instance of the class. @@ -72,13 +71,37 @@ public AutodiscoverRemoteException( : base(message, innerException) { this.error = error; - } + } - /// - /// Gets the error. - /// - /// The error. - public AutodiscoverError Error + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + protected AutodiscoverRemoteException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + this.error = (AutodiscoverError)info.GetValue("Error", typeof(AutodiscoverError)); + } + + /// Sets the object with the parameter name and additional exception information. + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + /// The object is a null reference (Nothing in Visual Basic). + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + EwsUtilities.Assert(info != null, "AutodiscoverRemoteException.GetObjectData", "info is null"); + + base.GetObjectData(info, context); + + info.AddValue("Error", this.error, typeof(Uri)); + } + + /// + /// Gets the error. + /// + /// The error. + public AutodiscoverError Error { get { return this.error; } } diff --git a/Exceptions/AutodiscoverResponseException.cs b/Exceptions/AutodiscoverResponseException.cs index c4b5cfa9..31179823 100644 --- a/Exceptions/AutodiscoverResponseException.cs +++ b/Exceptions/AutodiscoverResponseException.cs @@ -26,8 +26,7 @@ namespace Microsoft.Exchange.WebServices.Autodiscover { using System; - using System.Collections.Generic; - using System.Text; + using System.Runtime.Serialization; using Microsoft.Exchange.WebServices.Data; /// @@ -39,7 +38,7 @@ public class AutodiscoverResponseException : ServiceRemoteException /// /// Error code when Autodiscover service operation failed remotely. /// - private AutodiscoverErrorCode errorCode; + private readonly AutodiscoverErrorCode errorCode; /// /// Initializes a new instance of the class. @@ -50,12 +49,36 @@ internal AutodiscoverResponseException(AutodiscoverErrorCode errorCode, string m : base(message) { this.errorCode = errorCode; - } + } - /// - /// Gets the ErrorCode for the exception. - /// - public AutodiscoverErrorCode ErrorCode + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + protected AutodiscoverResponseException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + this.errorCode = (AutodiscoverErrorCode)info.GetInt32("ErrorCode"); + } + + /// Sets the object with the parameter name and additional exception information. + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + /// The object is a null reference (Nothing in Visual Basic). + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + EwsUtilities.Assert(info != null, "AutodiscoverResponseException.GetObjectData", "info is null"); + + base.GetObjectData(info, context); + + info.AddValue("ErrorCode", (int)this.errorCode); + } + + /// + /// Gets the ErrorCode for the exception. + /// + public AutodiscoverErrorCode ErrorCode { get { return this.errorCode; } } diff --git a/Exceptions/BatchServiceResponseException.cs b/Exceptions/BatchServiceResponseException.cs index bc047bde..3a79596f 100644 --- a/Exceptions/BatchServiceResponseException.cs +++ b/Exceptions/BatchServiceResponseException.cs @@ -26,8 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; - using System.Collections.Generic; - using System.Text; + using System.Runtime.Serialization; /// /// Represents a remote service exception that can have multiple service responses. @@ -40,7 +39,7 @@ public abstract class BatchServiceResponseException : ServiceRemoteEx /// /// The list of responses returned by the web method. /// - private ServiceResponseCollection responses; + private readonly ServiceResponseCollection responses; /// /// Initializes a new instance of MultiServiceResponseException. @@ -78,12 +77,36 @@ internal BatchServiceResponseException( "serviceResponses is null"); this.responses = serviceResponses; - } + } - /// - /// Gets a list of responses returned by the web method. - /// - public ServiceResponseCollection ServiceResponses + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + protected BatchServiceResponseException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + this.responses = (ServiceResponseCollection)info.GetValue("Responses", typeof(ServiceResponseCollection)); + } + + /// Sets the object with the parameter name and additional exception information. + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + /// The object is a null reference (Nothing in Visual Basic). + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + EwsUtilities.Assert(info != null, "BatchServiceResponseException.GetObjectData", "info is null"); + + base.GetObjectData(info, context); + + info.AddValue("Responses", this.responses, typeof(ServiceResponseCollection)); + } + + /// + /// Gets a list of responses returned by the web method. + /// + public ServiceResponseCollection ServiceResponses { get { return this.responses; } } diff --git a/Exceptions/CreateAttachmentException.cs b/Exceptions/CreateAttachmentException.cs index 6f607c2d..5768a14c 100644 --- a/Exceptions/CreateAttachmentException.cs +++ b/Exceptions/CreateAttachmentException.cs @@ -26,8 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; - using System.Collections.Generic; - using System.Text; + using System.Runtime.Serialization; /// /// Represents an error that occurs when a call to the CreateAttachment web method fails. @@ -59,6 +58,16 @@ internal CreateAttachmentException( Exception innerException) : base(serviceResponses, message, innerException) { - } - } + } + + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + private CreateAttachmentException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } } \ No newline at end of file diff --git a/Exceptions/DeleteAttachmentException.cs b/Exceptions/DeleteAttachmentException.cs index ebd6475c..db5bbede 100644 --- a/Exceptions/DeleteAttachmentException.cs +++ b/Exceptions/DeleteAttachmentException.cs @@ -26,13 +26,12 @@ namespace Microsoft.Exchange.WebServices.Data { using System; - using System.Collections.Generic; - using System.Text; + using System.Runtime.Serialization; - /// - /// Represents an error that occurs when a call to the DeleteAttachment web method fails. - /// - [Serializable] + /// + /// Represents an error that occurs when a call to the DeleteAttachment web method fails. + /// + [Serializable] public sealed class DeleteAttachmentException : BatchServiceResponseException { /// @@ -59,6 +58,16 @@ internal DeleteAttachmentException( Exception innerException) : base(serviceResponses, message, innerException) { - } - } + } + + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + private DeleteAttachmentException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } } \ No newline at end of file diff --git a/Exceptions/DnsException.cs b/Exceptions/DnsException.cs index 14eb8171..9c1d88c1 100644 --- a/Exceptions/DnsException.cs +++ b/Exceptions/DnsException.cs @@ -27,6 +27,7 @@ namespace Microsoft.Exchange.WebServices.Dns { using System; using System.ComponentModel; + using System.Runtime.Serialization; /// /// Represents an error that occurs when performing a DNS operation. @@ -41,6 +42,16 @@ internal class DnsException : Win32Exception internal DnsException(int errorCode) : base(errorCode) { - } - } + } + + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + protected DnsException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } } \ No newline at end of file diff --git a/Exceptions/PropertyException.cs b/Exceptions/PropertyException.cs index 36c6cec3..cfa9c786 100644 --- a/Exceptions/PropertyException.cs +++ b/Exceptions/PropertyException.cs @@ -23,11 +23,11 @@ * DEALINGS IN THE SOFTWARE. */ + namespace Microsoft.Exchange.WebServices.Data { using System; - using System.Collections.Generic; - using System.Text; + using System.Runtime.Serialization; /// /// Represents an error that occurs when an operation on a property fails. @@ -38,7 +38,7 @@ public class PropertyException : ServiceLocalException /// /// The name of the property that is at the origin of the exception. /// - private string name; + private readonly string name; /// /// PropertyException constructor. @@ -74,12 +74,36 @@ public PropertyException( : base(message, innerException) { this.name = name; - } + } - /// - /// Gets the name of the property that caused the exception. - /// - public string Name + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + protected PropertyException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + this.name = info.GetString("PropertyName"); + } + + /// Sets the object with the parameter name and additional exception information. + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + /// The object is a null reference (Nothing in Visual Basic). + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + EwsUtilities.Assert(info != null, "PropertyException.GetObjectData", "info is null"); + + base.GetObjectData(info, context); + + info.AddValue("PropertyName", this.name); + } + + /// + /// Gets the name of the property that caused the exception. + /// + public string Name { get { return this.name; } } diff --git a/Exceptions/ServerBusyException.cs b/Exceptions/ServerBusyException.cs index 561db945..eacc8fe6 100644 --- a/Exceptions/ServerBusyException.cs +++ b/Exceptions/ServerBusyException.cs @@ -26,6 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; + using System.Runtime.Serialization; /// /// Represents a server busy exception found in a service response. @@ -34,7 +35,7 @@ namespace Microsoft.Exchange.WebServices.Data public class ServerBusyException : ServiceResponseException { private const string BackOffMillisecondsKey = @"BackOffMilliseconds"; - private int backOffMilliseconds; + private readonly int backOffMilliseconds; /// /// Initializes a new instance of the class. @@ -47,13 +48,37 @@ public ServerBusyException(ServiceResponse response) { Int32.TryParse(response.ErrorDetails[ServerBusyException.BackOffMillisecondsKey], out this.backOffMilliseconds); } - } - - /// - /// Suggested number of milliseconds to wait before attempting a request again. If zero, - /// there is no suggested backoff time. - /// - public int BackOffMilliseconds + } + + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + protected ServerBusyException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + this.backOffMilliseconds = info.GetInt32("BackOffMilliseconds"); + } + + /// Sets the object with the parameter name and additional exception information. + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + /// The object is a null reference (Nothing in Visual Basic). + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + EwsUtilities.Assert(info != null, "ServerBusyException.GetObjectData", "info is null"); + + base.GetObjectData(info, context); + + info.AddValue("BackOffMilliseconds", this.backOffMilliseconds); + } + + /// + /// Suggested number of milliseconds to wait before attempting a request again. If zero, + /// there is no suggested backoff time. + /// + public int BackOffMilliseconds { get { diff --git a/Exceptions/ServiceLocalException.cs b/Exceptions/ServiceLocalException.cs index 0b66a309..9a4000d0 100644 --- a/Exceptions/ServiceLocalException.cs +++ b/Exceptions/ServiceLocalException.cs @@ -26,8 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; - using System.Collections.Generic; - using System.Text; + using System.Runtime.Serialization; /// /// Represents an error that occurs when a service operation fails locally (e.g. validation error). @@ -61,5 +60,14 @@ public ServiceLocalException(string message, Exception innerException) : base(message, innerException) { } - } + + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + protected ServiceLocalException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } + } } \ No newline at end of file diff --git a/Exceptions/ServiceObjectPropertyException.cs b/Exceptions/ServiceObjectPropertyException.cs index 89c96b3a..8b3e7b51 100644 --- a/Exceptions/ServiceObjectPropertyException.cs +++ b/Exceptions/ServiceObjectPropertyException.cs @@ -26,8 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; - using System.Collections.Generic; - using System.Text; + using System.Runtime.Serialization; /// /// Represents an error that occurs when an operation on a property fails. @@ -38,7 +37,7 @@ public class ServiceObjectPropertyException : PropertyException /// /// The definition of the property that is at the origin of the exception. /// - private PropertyDefinitionBase propertyDefinition; + private readonly PropertyDefinitionBase propertyDefinition; /// /// ServiceObjectPropertyException constructor. @@ -74,12 +73,36 @@ public ServiceObjectPropertyException( : base(message, propertyDefinition.GetPrintableName(), innerException) { this.propertyDefinition = propertyDefinition; - } + } - /// - /// Gets the definition of the property that caused the exception. - /// - public PropertyDefinitionBase PropertyDefinition + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + protected ServiceObjectPropertyException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + this.propertyDefinition = (PropertyDefinitionBase)info.GetValue("PropertyDefinition", typeof(PropertyDefinitionBase)); + } + + /// Sets the object with the parameter name and additional exception information. + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + /// The object is a null reference (Nothing in Visual Basic). + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + EwsUtilities.Assert(info != null, "ServiceObjectPropertyException.GetObjectData", "info is null"); + + base.GetObjectData(info, context); + + info.AddValue("PropertyDefinition", this.propertyDefinition, typeof(PropertyDefinitionBase)); + } + + /// + /// Gets the definition of the property that caused the exception. + /// + public PropertyDefinitionBase PropertyDefinition { get { return this.propertyDefinition; } } diff --git a/Exceptions/ServiceRemoteException.cs b/Exceptions/ServiceRemoteException.cs index a32141f3..89df2ef9 100644 --- a/Exceptions/ServiceRemoteException.cs +++ b/Exceptions/ServiceRemoteException.cs @@ -25,41 +25,50 @@ namespace Microsoft.Exchange.WebServices.Data { - using System; - using System.Collections.Generic; - using System.Text; + using System; + using System.Runtime.Serialization; - /// - /// Represents an error that occurs when a service operation fails remotely. - /// - [Serializable] - public class ServiceRemoteException : Exception - { - /// - /// ServiceRemoteException Constructor. - /// - public ServiceRemoteException() - : base() - { - } + /// + /// Represents an error that occurs when a service operation fails remotely. + /// + [Serializable] + public class ServiceRemoteException : Exception + { + /// + /// ServiceRemoteException Constructor. + /// + public ServiceRemoteException() + : base() + { + } - /// - /// ServiceRemoteException Constructor. - /// - /// Error message text. - public ServiceRemoteException(string message) - : base(message) - { - } + /// + /// ServiceRemoteException Constructor. + /// + /// Error message text. + public ServiceRemoteException(string message) + : base(message) + { + } - /// - /// ServiceRemoteException Constructor. - /// - /// Error message text. - /// Inner exception. - public ServiceRemoteException(string message, Exception innerException) - : base(message, innerException) - { - } - } + /// + /// ServiceRemoteException Constructor. + /// + /// Error message text. + /// Inner exception. + public ServiceRemoteException(string message, Exception innerException) + : base(message, innerException) + { + } + + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + protected ServiceRemoteException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } } \ No newline at end of file diff --git a/Exceptions/ServiceRequestException.cs b/Exceptions/ServiceRequestException.cs index f29e3cd9..cbb52f83 100644 --- a/Exceptions/ServiceRequestException.cs +++ b/Exceptions/ServiceRequestException.cs @@ -26,8 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; - using System.Collections.Generic; - using System.Text; + using System.Runtime.Serialization; /// /// Represents an error that occurs when a service operation request fails (e.g. connection error). @@ -60,6 +59,16 @@ public ServiceRequestException(string message) public ServiceRequestException(string message, Exception innerException) : base(message, innerException) { - } - } + } + + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + protected ServiceRequestException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } } \ No newline at end of file diff --git a/Exceptions/ServiceResponseException.cs b/Exceptions/ServiceResponseException.cs index a1e5e6ae..703cfdde 100644 --- a/Exceptions/ServiceResponseException.cs +++ b/Exceptions/ServiceResponseException.cs @@ -26,6 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; + using System.Runtime.Serialization; /// /// Represents a remote service exception that has a single response. @@ -43,7 +44,7 @@ public class ServiceResponseException : ServiceRemoteException /// /// ServiceResponse when service operation failed remotely. /// - private ServiceResponse response; + private readonly ServiceResponse response; /// /// Initializes a new instance of the class. @@ -52,12 +53,36 @@ public class ServiceResponseException : ServiceRemoteException internal ServiceResponseException(ServiceResponse response) { this.response = response; - } + } - /// - /// Gets the ServiceResponse for the exception. - /// - public ServiceResponse Response + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + protected ServiceResponseException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + this.response = (ServiceResponse)info.GetValue("Response", typeof(ServiceResponse)); + } + + /// Sets the object with the parameter name and additional exception information. + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + /// The object is a null reference (Nothing in Visual Basic). + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + EwsUtilities.Assert(info != null, "ServiceResponseException.GetObjectData", "info is null"); + + base.GetObjectData(info, context); + + info.AddValue("Response", this.response, typeof(ServiceResponse)); + } + + /// + /// Gets the ServiceResponse for the exception. + /// + public ServiceResponse Response { get { return this.response; } } diff --git a/Exceptions/ServiceValidationException.cs b/Exceptions/ServiceValidationException.cs index d3459d0e..0e442a3e 100644 --- a/Exceptions/ServiceValidationException.cs +++ b/Exceptions/ServiceValidationException.cs @@ -26,8 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; - using System.Collections.Generic; - using System.Text; + using System.Runtime.Serialization; /// /// Represents an error that occurs when a validation check fails. @@ -60,6 +59,16 @@ public ServiceValidationException(string message) public ServiceValidationException(string message, Exception innerException) : base(message, innerException) { - } - } + } + + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + private ServiceValidationException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } } \ No newline at end of file diff --git a/Exceptions/ServiceVersionException.cs b/Exceptions/ServiceVersionException.cs index 72d45044..fb66f83c 100644 --- a/Exceptions/ServiceVersionException.cs +++ b/Exceptions/ServiceVersionException.cs @@ -26,8 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; - using System.Collections.Generic; - using System.Text; + using System.Runtime.Serialization; /// /// Represents an error that occurs when a request cannot be handled due to a service version mismatch. @@ -60,6 +59,16 @@ public ServiceVersionException(string message) public ServiceVersionException(string message, Exception innerException) : base(message, innerException) { - } - } + } + + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + private ServiceVersionException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } } \ No newline at end of file diff --git a/Exceptions/ServiceXmlDeserializationException.cs b/Exceptions/ServiceXmlDeserializationException.cs index 95482cf7..59ade3a8 100644 --- a/Exceptions/ServiceXmlDeserializationException.cs +++ b/Exceptions/ServiceXmlDeserializationException.cs @@ -26,8 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; - using System.Collections.Generic; - using System.Text; + using System.Runtime.Serialization; /// /// Represents an error that occurs when the XML for a response cannot be deserialized. @@ -60,6 +59,16 @@ public ServiceXmlDeserializationException(string message) public ServiceXmlDeserializationException(string message, Exception innerException) : base(message, innerException) { - } - } + } + + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + private ServiceXmlDeserializationException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } } \ No newline at end of file diff --git a/Exceptions/ServiceXmlSerializationException.cs b/Exceptions/ServiceXmlSerializationException.cs index 928cec3e..1a7a2265 100644 --- a/Exceptions/ServiceXmlSerializationException.cs +++ b/Exceptions/ServiceXmlSerializationException.cs @@ -26,8 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; - using System.Collections.Generic; - using System.Text; + using System.Runtime.Serialization; /// /// Represents an error that occurs when the XML for a request cannot be serialized. @@ -60,6 +59,16 @@ public ServiceXmlSerializationException(string message) public ServiceXmlSerializationException(string message, Exception innerException) : base(message, innerException) { - } - } + } + + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + protected ServiceXmlSerializationException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } } \ No newline at end of file diff --git a/Exceptions/TimeZoneConversionException.cs b/Exceptions/TimeZoneConversionException.cs index a54b3f6d..81bdf74b 100644 --- a/Exceptions/TimeZoneConversionException.cs +++ b/Exceptions/TimeZoneConversionException.cs @@ -26,8 +26,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; - using System.Collections.Generic; - using System.Text; + using System.Runtime.Serialization; /// /// Represents an error that occurs when a date and time cannot be converted from one time zone @@ -61,6 +60,16 @@ public TimeZoneConversionException(string message) public TimeZoneConversionException(string message, Exception innerException) : base(message, innerException) { - } - } + } + + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + protected TimeZoneConversionException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } } \ No newline at end of file diff --git a/Exceptions/UpdateInboxRulesException.cs b/Exceptions/UpdateInboxRulesException.cs index 48999a88..9d462e9f 100644 --- a/Exceptions/UpdateInboxRulesException.cs +++ b/Exceptions/UpdateInboxRulesException.cs @@ -27,7 +27,7 @@ namespace Microsoft.Exchange.WebServices.Data { using System; using System.Collections.Generic; - using Microsoft.Exchange.WebServices.Data; + using System.Runtime.Serialization; /// /// Represents an exception thrown when an error occurs as a result of calling @@ -39,12 +39,12 @@ public sealed class UpdateInboxRulesException : ServiceRemoteException /// /// ServiceResponse when service operation failed remotely. /// - private ServiceResponse serviceResponse; + private readonly ServiceResponse serviceResponse; /// /// Rule operation error collection. /// - private RuleOperationErrorCollection errors; + private readonly RuleOperationErrorCollection errors; /// /// Initializes a new instance of the class. @@ -60,12 +60,38 @@ internal UpdateInboxRulesException(UpdateInboxRulesResponse serviceResponse, IEn { error.SetOperationByIndex(ruleOperations); } - } + } - /// - /// Gets the ServiceResponse for the exception. - /// - public ServiceResponse ServiceResponse + /// + /// Initializes a new instance of the class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + private UpdateInboxRulesException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + this.serviceResponse = (ServiceResponse)info.GetValue("ServiceResponse", typeof(ServiceResponse)); + this.errors = (RuleOperationErrorCollection)info.GetValue("Errors", typeof(RuleOperationErrorCollection)); + } + + /// Sets the object with the parameter name and additional exception information. + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + /// The object is a null reference (Nothing in Visual Basic). + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + EwsUtilities.Assert(info != null, "UpdateInboxRulesException.GetObjectData", "info is null"); + + base.GetObjectData(info, context); + + info.AddValue("Errors", this.errors, typeof(RuleOperationErrorCollection)); + info.AddValue("ServiceResponse", this.serviceResponse, typeof(ServiceResponse)); + } + + /// + /// Gets the ServiceResponse for the exception. + /// + public ServiceResponse ServiceResponse { get { return this.serviceResponse; } }