@@ -4,6 +4,7 @@ import {ExchangeServiceBase} from "./ExchangeServiceBase";
44import { EwsUtilities } from "./EwsUtilities" ;
55import { XmlNamespace } from "../Enumerations/XmlNamespace" ;
66import { StringHelper , base64Helper } from "../ExtensionMethods" ;
7+ import { DateTime } from "../DateTime" ;
78
89/**
910 * XML writer
@@ -110,7 +111,8 @@ export class EwsServiceXmlWriter {
110111 var strValue : string = null ;
111112
112113 if ( value === null ) return null ;
113- if ( typeof ( value ) == "object" && ! ( value . GetSearchString /*ISearchStringProvider*/ ) ) throw new Error ( "value can not be of type object" ) ;
114+ // // // // if (typeof (value) == "object" && !(value.GetSearchString /*ISearchStringProvider*/))
115+ // // // // throw new Error("value can not be of type object");
114116
115117 if ( value != null ) {
116118 switch ( typeof ( value ) ) {
@@ -125,12 +127,18 @@ export class EwsServiceXmlWriter {
125127 case "string" :
126128 return value ;
127129 default :
130+ if ( value instanceof DateTime ) {
131+ return this . service . ConvertDateTimeToUniversalDateTimeString ( value as DateTime ) ;
132+ //return EwsUtilities.DateTimeToXSDateTime(value as DateTime);
133+ }
128134 try {
129- if ( typeof value . GetSearchString !== 'undefined' ) // checking - ISearchStringProvider
130- strValue = value . GetSearchString ( ) ;
135+ if ( typeof value . GetSearchString === 'function' ) // checking - ISearchStringProvider
136+ return value . GetSearchString ( ) ;
137+ else
138+ throw new Error ( "value can not be of type object" ) ;
131139 }
132140 catch ( e ) {
133- strValue = value ;
141+ throw e ;
134142 }
135143
136144 break ;
@@ -219,8 +227,8 @@ export class EwsServiceXmlWriter {
219227 var value : any = valueToWrite ;
220228 var alwaysWriteEmptyString : boolean = false ;
221229 var namespacePrefix : string = null ;
222- var callWithNameSpacePrifix :boolean = false ;
223-
230+ var callWithNameSpacePrifix : boolean = false ;
231+
224232 if ( argsLength === 2 ) {
225233 value = localNameOrAlwaysWriteEmptyStringOrValue ;
226234 }
@@ -239,7 +247,7 @@ export class EwsServiceXmlWriter {
239247 var stringValue : string = this . ConvertObjectToString ( value ) ;
240248 if ( ! StringHelper . IsNullOrEmpty ( stringValue ) || alwaysWriteEmptyString ) {
241249 this . WriteAttributeString (
242- callWithNameSpacePrifix ? namespacePrefix : "" ,
250+ callWithNameSpacePrifix ? namespacePrefix : "" ,
243251 localName ,
244252 stringValue ) ;
245253 }
@@ -255,7 +263,7 @@ export class EwsServiceXmlWriter {
255263 WriteBase64ElementValue ( buffer : any ) : void {
256264 this . WriteValue ( base64Helper . btoa ( buffer ) , null ) ;
257265 }
258-
266+
259267 /**
260268 * Writes the element value.
261269 *
@@ -295,7 +303,7 @@ export class EwsServiceXmlWriter {
295303 EwsLogging . Assert ( stringValue !== 'undefined' , 'WriteElementValue' , StringHelper . Format (
296304 Strings . ElementValueCannotBeSerialized ,
297305 typeof ( value ) , localName ) ) ;
298-
306+
299307 // throw new Error(StringHelper.Format(
300308 // Strings.ElementValueCannotBeSerialized,
301309 // typeof (value), localName));
0 commit comments