/// <summary> /// Initializes a new instance of the <see cref="EwsServiceXmlWriter"/> class. /// </summary> /// <param name="service">The service.</param> /// <param name="stream">The stream.</param> internal EwsServiceXmlWriter(ExchangeServiceBase service, Stream stream) { this.service = service; XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.Encoding = EwsServiceXmlWriter.utf8Encoding; this.xmlWriter = XmlWriter.Create(stream, settings); }
/// <summary> /// Initializes a new instance of the <see cref="EwsServiceXmlWriter"/> class. /// </summary> /// <param name="service">The service.</param> /// <param name="stream">The stream.</param> internal EwsServiceXmlWriter(ExchangeServiceBase service, Stream stream) { this.service = service; XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.Encoding = EwsServiceXmlWriter.utf8Encoding; this.xmlWriter = XmlWriter.Create(stream, settings); }
/// <summary> /// Gets the type code. /// </summary> /// <param name="service">The service.</param> /// <param name="dictionaryObject">The dictionary object.</param> /// <param name="dictionaryObjectType">Type of the dictionary object.</param> /// <param name="valueAsString">The value as string.</param> private static void GetTypeCode(ExchangeServiceBase service, object dictionaryObject, ref UserConfigurationDictionaryObjectType dictionaryObjectType, ref string valueAsString) { // Handle all other types by TypeCode Type type = dictionaryObject.GetType(); if (type == typeof(bool)) { dictionaryObjectType = UserConfigurationDictionaryObjectType.Boolean; valueAsString = EwsUtilities.BoolToXSBool((bool)dictionaryObject); } else if (type == typeof(byte)) { dictionaryObjectType = UserConfigurationDictionaryObjectType.Byte; valueAsString = ((byte)dictionaryObject).ToString(); } else if (type == typeof(DateTime)) { dictionaryObjectType = UserConfigurationDictionaryObjectType.DateTime; valueAsString = service.ConvertDateTimeToUniversalDateTimeString((DateTime)dictionaryObject); } else if (type == typeof(Int32)) { dictionaryObjectType = UserConfigurationDictionaryObjectType.Integer32; valueAsString = ((int)dictionaryObject).ToString(); } else if (type == typeof(Int64)) { dictionaryObjectType = UserConfigurationDictionaryObjectType.Integer64; valueAsString = ((long)dictionaryObject).ToString(); } else if (type == typeof(string)) { dictionaryObjectType = UserConfigurationDictionaryObjectType.String; valueAsString = (string)dictionaryObject; } else if (type == typeof(UInt32)) { dictionaryObjectType = UserConfigurationDictionaryObjectType.UnsignedInteger32; valueAsString = ((uint)dictionaryObject).ToString(); } else if (type == typeof(UInt64)) { dictionaryObjectType = UserConfigurationDictionaryObjectType.UnsignedInteger64; valueAsString = ((ulong)dictionaryObject).ToString(); } else { EwsUtilities.Assert( false, "UserConfigurationDictionary.WriteObjectValueToXml", "Unsupported type: " + dictionaryObject.GetType().ToString()); } }
/// <summary> /// Gets the type code. /// </summary> /// <param name="service">The service.</param> /// <param name="dictionaryObject">The dictionary object.</param> /// <param name="dictionaryObjectType">Type of the dictionary object.</param> /// <param name="valueAsString">The value as string.</param> private static void GetTypeCode(ExchangeServiceBase service, object dictionaryObject, ref UserConfigurationDictionaryObjectType dictionaryObjectType, ref string valueAsString) { // Handle all other types by TypeCode switch (Type.GetTypeCode(dictionaryObject.GetType())) { case TypeCode.Boolean: dictionaryObjectType = UserConfigurationDictionaryObjectType.Boolean; valueAsString = EwsUtilities.BoolToXSBool((bool)dictionaryObject); break; case TypeCode.Byte: dictionaryObjectType = UserConfigurationDictionaryObjectType.Byte; valueAsString = ((byte)dictionaryObject).ToString(); break; case TypeCode.DateTime: dictionaryObjectType = UserConfigurationDictionaryObjectType.DateTime; valueAsString = service.ConvertDateTimeToUniversalDateTimeString((DateTime)dictionaryObject); break; case TypeCode.Int32: dictionaryObjectType = UserConfigurationDictionaryObjectType.Integer32; valueAsString = ((int)dictionaryObject).ToString(); break; case TypeCode.Int64: dictionaryObjectType = UserConfigurationDictionaryObjectType.Integer64; valueAsString = ((long)dictionaryObject).ToString(); break; case TypeCode.String: dictionaryObjectType = UserConfigurationDictionaryObjectType.String; valueAsString = (string)dictionaryObject; break; case TypeCode.UInt32: dictionaryObjectType = UserConfigurationDictionaryObjectType.UnsignedInteger32; valueAsString = ((uint)dictionaryObject).ToString(); break; case TypeCode.UInt64: dictionaryObjectType = UserConfigurationDictionaryObjectType.UnsignedInteger64; valueAsString = ((ulong)dictionaryObject).ToString(); break; default: EwsUtilities.Assert( false, "UserConfigurationDictionary.WriteObjectValueToXml", "Unsupported type: " + dictionaryObject.GetType().ToString()); break; } }
/// <summary> /// Initializes a new instance of the <see cref="ExchangeServiceBase"/> class. /// </summary> /// <param name="service">The other service.</param> /// <param name="requestedServerVersion">The requested server version.</param> internal ExchangeServiceBase(ExchangeServiceBase service, ExchangeVersion requestedServerVersion) : this(requestedServerVersion) { this.useDefaultCredentials = service.useDefaultCredentials; this.credentials = service.credentials; this.traceEnabled = service.traceEnabled; this.traceListener = service.traceListener; this.traceFlags = service.traceFlags; this.timeout = service.timeout; this.preAuthenticate = service.preAuthenticate; this.userAgent = service.userAgent; this.acceptGzipEncoding = service.acceptGzipEncoding; this.keepAlive = service.keepAlive; this.connectionGroupName = service.connectionGroupName; this.timeZone = service.timeZone; this.httpHeaders = service.httpHeaders; this.ewsHttpWebRequestFactory = service.ewsHttpWebRequestFactory; }
/// <summary> /// Gets the converted date time. /// </summary> /// <param name="service">The service.</param> /// <param name="propertyBag">The property bag.</param> /// <param name="isUpdateOperation">if set to <c>true</c> [is update operation].</param> /// <param name="value">The value.</param> /// <returns></returns> private DateTime GetConvertedDateTime(ExchangeServiceBase service, PropertyBag propertyBag, bool isUpdateOperation, object value) { DateTime dateTime = (DateTime)value; DateTime convertedDateTime; // If the date/time is unspecified, we may need to scope it to time zone. if (dateTime.Kind == DateTimeKind.Unspecified) { convertedDateTime = this.ScopeToTimeZone( service, (DateTime)value, propertyBag, isUpdateOperation); } else { convertedDateTime = dateTime; } return(convertedDateTime); }
/// <summary> /// Scopes the date time property to the appropriate time zone, if necessary. /// </summary> /// <param name="service">The service emitting the request.</param> /// <param name="dateTime">The date time.</param> /// <param name="propertyBag">The property bag.</param> /// <param name="isUpdateOperation">Indicates whether the scoping is to be performed in the context of an update operation.</param> /// <returns>The converted DateTime.</returns> internal virtual DateTime ScopeToTimeZone( ExchangeServiceBase service, DateTime dateTime, PropertyBag propertyBag, bool isUpdateOperation) { try { DateTime convertedDateTime = EwsUtilities.ConvertTime( dateTime, service.TimeZone, TimeZoneInfo.Utc); return(new DateTime(convertedDateTime.Ticks, DateTimeKind.Utc)); } catch (TimeZoneConversionException e) { throw new PropertyException( string.Format(Strings.InvalidDateTime, dateTime), this.Name, e); } }
/// <summary> /// Scopes the date time property to the appropriate time zone, if necessary. /// </summary> /// <param name="service">The service emitting the request.</param> /// <param name="dateTime">The date time.</param> /// <param name="propertyBag">The property bag.</param> /// <param name="isUpdateOperation">Indicates whether the scoping is to be performed in the context of an update operation.</param> /// <returns>The converted DateTime.</returns> internal override DateTime ScopeToTimeZone( ExchangeServiceBase service, DateTime dateTime, PropertyBag propertyBag, bool isUpdateOperation) { if (!propertyBag.Owner.GetIsCustomDateTimeScopingRequired()) { // Most item types do not require a custom scoping mechanism. For those item types, // use the default scoping mechanism. return base.ScopeToTimeZone( service, dateTime, propertyBag, isUpdateOperation); } else { // Appointment, however, requires a custom scoping mechanism which is based on an // associated time zone property. PropertyDefinition timeZoneProperty = this.GetTimeZoneProperty(service.RequestedServerVersion); object timeZonePropertyValue = null; bool timeZonePropertyIsSet = propertyBag.TryGetProperty(timeZoneProperty, out timeZonePropertyValue); if (timeZonePropertyValue != null && propertyBag.IsPropertyUpdated(timeZoneProperty)) { // If we have the associated time zone property handy and if it has been updated locally, // then we scope the date time to that time zone. try { DateTime convertedDateTime = EwsUtilities.ConvertTime( dateTime, (TimeZoneInfo)timeZonePropertyValue, TimeZoneInfo.Utc); // This is necessary to stamp the date/time with the Local kind. return new DateTime(convertedDateTime.Ticks, DateTimeKind.Utc); } catch (TimeZoneConversionException e) { throw new PropertyException( string.Format(Strings.InvalidDateTime, dateTime), this.Name, e); } } else { if (isUpdateOperation) { // In an update operation, what we do depends on what version of EWS // we are targeting. if (service.RequestedServerVersion == ExchangeVersion.Exchange2007_SP1) { // For Exchange 2007 SP1, we still need to scope to the service's time zone. return base.ScopeToTimeZone( service, dateTime, propertyBag, isUpdateOperation); } else { // Otherwise, we let the server scope to the appropriate time zone. return dateTime; } } else { // In a Create operation, always scope to the service's time zone. return base.ScopeToTimeZone( service, dateTime, propertyBag, isUpdateOperation); } } } }
/// <summary> /// Initializes a new instance of the <see cref="DirectoryHelper"/> class. /// </summary> /// <param name="service">The service.</param> public DirectoryHelper(ExchangeServiceBase service) { this.service = service; }
/// <summary> /// Gets the type code. /// </summary> /// <param name="service">The service.</param> /// <param name="dictionaryObject">The dictionary object.</param> /// <param name="dictionaryObjectType">Type of the dictionary object.</param> /// <param name="valueAsString">The value as string.</param> private static void GetTypeCode(ExchangeServiceBase service, object dictionaryObject, ref UserConfigurationDictionaryObjectType dictionaryObjectType, ref string valueAsString) { // Handle all other types by TypeCode switch (Type.GetTypeCode(dictionaryObject.GetType())) { case TypeCode.Boolean: dictionaryObjectType = UserConfigurationDictionaryObjectType.Boolean; valueAsString = EwsUtilities.BoolToXSBool((bool)dictionaryObject); break; case TypeCode.Byte: dictionaryObjectType = UserConfigurationDictionaryObjectType.Byte; valueAsString = ((byte)dictionaryObject).ToString(); break; case TypeCode.DateTime: dictionaryObjectType = UserConfigurationDictionaryObjectType.DateTime; valueAsString = service.ConvertDateTimeToUniversalDateTimeString((DateTime)dictionaryObject); break; case TypeCode.Int32: dictionaryObjectType = UserConfigurationDictionaryObjectType.Integer32; valueAsString = ((int)dictionaryObject).ToString(); break; case TypeCode.Int64: dictionaryObjectType = UserConfigurationDictionaryObjectType.Integer64; valueAsString = ((long)dictionaryObject).ToString(); break; case TypeCode.String: dictionaryObjectType = UserConfigurationDictionaryObjectType.String; valueAsString = (string)dictionaryObject; break; case TypeCode.UInt32: dictionaryObjectType = UserConfigurationDictionaryObjectType.UnsignedInteger32; valueAsString = ((uint)dictionaryObject).ToString(); break; case TypeCode.UInt64: dictionaryObjectType = UserConfigurationDictionaryObjectType.UnsignedInteger64; valueAsString = ((ulong)dictionaryObject).ToString(); break; default: EwsUtilities.Assert( false, "UserConfigurationDictionary.WriteObjectValueToXml", "Unsupported type: " + dictionaryObject.GetType().ToString()); break; } }
/// <summary> /// Initializes a new instance of the <see cref="ExchangeServiceBase"/> class from existing one. /// </summary> /// <param name="service">The other service.</param> internal ExchangeServiceBase(ExchangeServiceBase service) : this(service, service.RequestedServerVersion) { }
/// <summary> /// Initializes a new instance of the <see cref="ExchangeServiceBase"/> class. /// </summary> /// <param name="service">The other service.</param> /// <param name="requestedServerVersion">The requested server version.</param> internal ExchangeServiceBase(ExchangeServiceBase service, ExchangeVersion requestedServerVersion) : this(requestedServerVersion) { this.useDefaultCredentials = service.useDefaultCredentials; this.credentials = service.credentials; this.traceEnabled = service.traceEnabled; this.traceListener = service.traceListener; this.traceFlags = service.traceFlags; this.timeout = service.timeout; this.preAuthenticate = service.preAuthenticate; this.userAgent = service.userAgent; this.acceptGzipEncoding = service.acceptGzipEncoding; this.keepAlive = service.keepAlive; this.connectionGroupName = service.connectionGroupName; this.timeZone = service.timeZone; this.httpHeaders = service.httpHeaders; this.ewsHttpWebRequestFactory = service.ewsHttpWebRequestFactory; }
/// <summary> /// Gets the converted date time. /// </summary> /// <param name="service">The service.</param> /// <param name="propertyBag">The property bag.</param> /// <param name="isUpdateOperation">if set to <c>true</c> [is update operation].</param> /// <param name="value">The value.</param> /// <returns></returns> private DateTime GetConvertedDateTime(ExchangeServiceBase service, PropertyBag propertyBag, bool isUpdateOperation, object value) { DateTime dateTime = (DateTime)value; DateTime convertedDateTime; // If the date/time is unspecified, we may need to scope it to time zone. if (dateTime.Kind == DateTimeKind.Unspecified) { convertedDateTime = this.ScopeToTimeZone( service, (DateTime)value, propertyBag, isUpdateOperation); } else { convertedDateTime = dateTime; } return convertedDateTime; }
/// <summary> /// Scopes the date time property to the appropriate time zone, if necessary. /// </summary> /// <param name="service">The service emitting the request.</param> /// <param name="dateTime">The date time.</param> /// <param name="propertyBag">The property bag.</param> /// <param name="isUpdateOperation">Indicates whether the scoping is to be performed in the context of an update operation.</param> /// <returns>The converted DateTime.</returns> internal virtual DateTime ScopeToTimeZone( ExchangeServiceBase service, DateTime dateTime, PropertyBag propertyBag, bool isUpdateOperation) { try { DateTime convertedDateTime = EwsUtilities.ConvertTime( dateTime, service.TimeZone, TimeZoneInfo.Utc); return new DateTime(convertedDateTime.Ticks, DateTimeKind.Utc); } catch (TimeZoneConversionException e) { throw new PropertyException( string.Format(Strings.InvalidDateTime, dateTime), this.Name, e); } }
/// <summary> /// Scopes the date time property to the appropriate time zone, if necessary. /// </summary> /// <param name="service">The service emitting the request.</param> /// <param name="dateTime">The date time.</param> /// <param name="propertyBag">The property bag.</param> /// <param name="isUpdateOperation">Indicates whether the scoping is to be performed in the context of an update operation.</param> /// <returns>The converted DateTime.</returns> internal override DateTime ScopeToTimeZone( ExchangeServiceBase service, DateTime dateTime, PropertyBag propertyBag, bool isUpdateOperation) { if (!propertyBag.Owner.GetIsCustomDateTimeScopingRequired()) { // Most item types do not require a custom scoping mechanism. For those item types, // use the default scoping mechanism. return(base.ScopeToTimeZone( service, dateTime, propertyBag, isUpdateOperation)); } else { // Appointment, however, requires a custom scoping mechanism which is based on an // associated time zone property. PropertyDefinition timeZoneProperty = this.GetTimeZoneProperty(service.RequestedServerVersion); object timeZonePropertyValue = null; bool timeZonePropertyIsSet = propertyBag.TryGetProperty(timeZoneProperty, out timeZonePropertyValue); if (timeZonePropertyValue != null && propertyBag.IsPropertyUpdated(timeZoneProperty)) { // If we have the associated time zone property handy and if it has been updated locally, // then we scope the date time to that time zone. try { DateTime convertedDateTime = EwsUtilities.ConvertTime( dateTime, (TimeZoneInfo)timeZonePropertyValue, TimeZoneInfo.Utc); // This is necessary to stamp the date/time with the Local kind. return(new DateTime(convertedDateTime.Ticks, DateTimeKind.Utc)); } catch (TimeZoneConversionException e) { throw new PropertyException( string.Format(Strings.InvalidDateTime, dateTime), this.Name, e); } } else { if (isUpdateOperation) { // In an update operation, what we do depends on what version of EWS // we are targeting. if (service.RequestedServerVersion == ExchangeVersion.Exchange2007_SP1) { // For Exchange 2007 SP1, we still need to scope to the service's time zone. return(base.ScopeToTimeZone( service, dateTime, propertyBag, isUpdateOperation)); } else { // Otherwise, we let the server scope to the appropriate time zone. return(dateTime); } } else { // In a Create operation, always scope to the service's time zone. return(base.ScopeToTimeZone( service, dateTime, propertyBag, isUpdateOperation)); } } } }
/// <summary> /// Initializes a new instance of the <see cref="ExchangeServiceBase"/> class from existing one. /// </summary> /// <param name="service">The other service.</param> internal ExchangeServiceBase(ExchangeServiceBase service) : this(service, service.RequestedServerVersion) { }
/// <summary> /// Initializes a new instance of the <see cref="ExchangeServiceBase"/> class from existing one. /// </summary> /// <param name="service">The other service.</param> internal ExchangeServiceBase(ExchangeServiceBase serviceBase) { }