Skip to content

Commit cbfc336

Browse files
committed
reverted back Schema properties to static after proper implementation and code updates. Also replaced ServiceObject related instanceof call with TypeContainer
1 parent cea338e commit cbfc336

33 files changed

+4293
-3261
lines changed

src/js/Core/PropertyBag.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,25 @@ import {ServiceObject} from "./ServiceObjects/ServiceObject";
77
import {PropertySet} from "./PropertySet";
88
import {ComplexProperty} from "../ComplexProperties/ComplexProperty";
99
import {IOutParam} from "../Interfaces/IOutParam";
10+
import {Item} from "./ServiceObjects/Items/Item";
1011
import {Folder} from "./ServiceObjects/Folders/Folder";
1112
import {ComplexPropertyDefinitionBase} from "../PropertyDefinitions/ComplexPropertyDefinitionBase";
1213
import {IOwnedProperty} from "../Interfaces/IOwnedProperty";
1314
import {BasePropertySet} from "../Enumerations/BasePropertySet";
1415
import {EwsServiceXmlReader} from "./EwsServiceXmlReader";
1516
import {ISelfValidate} from "../Interfaces/ISelfValidate";
16-
1717
import {ExchangeVersion} from "../Enumerations/ExchangeVersion";
1818
import {PropertyDefinitionFlags} from "../Enumerations/PropertyDefinitionFlags";
1919
import {EwsServiceXmlWriter} from "./EwsServiceXmlWriter";
2020
import {EwsUtilities} from "./EwsUtilities";
2121
import {EwsLogging} from "./EwsLogging";
2222
import {XmlElementNames} from "../Core/XmlElementNames";
2323
import {XmlNamespace} from "../Enumerations/XmlNamespace";
24-
2524
import {ICustomUpdateSerializer} from "../Interfaces/ICustomXmlUpdateSerializer";
26-
2725
import {PropertyDefinition} from "../PropertyDefinitions/PropertyDefinition";
28-
2926
import {DictionaryWithPropertyDefitionKey, KeyValuePair} from "../AltDictionary";
30-
3127
import {StringHelper, TypeSystem} from "../ExtensionMethods";
28+
import {TypeContainer} from "../TypeContainer";
3229

3330

3431
//todo: should be done
@@ -135,8 +132,7 @@ export class PropertyBag {
135132
return false;
136133
}
137134
static GetPropertyUpdateItemName(serviceObject: ServiceObject): string {
138-
//return serviceObject instanceof Folder ?
139-
return serviceObject.InstanceType === XmlElementNames.Folder ? //removed instanceof operation to remove circular dependency.
135+
return serviceObject instanceof TypeContainer.Folder ? //ref: //info: TypeContainer contains constructor of Folder (not instance) to evade circular dependency. Assigned at bootstarp
140136
XmlElementNames.Folder :
141137
XmlElementNames.Item;
142138
}
@@ -344,10 +340,10 @@ export class PropertyBag {
344340

345341
if (!this.Owner.IsNew) {
346342
// If owner is an item attachment, properties cannot be updated (EWS doesn't support updating item attachments)
347-
var isItem = this.owner.InstanceType === XmlElementNames.Item;// this.owner instanceof Item;
343+
var isItem = this.owner instanceof TypeContainer.Item; //ref: //info: TypeContainer contains constructor of Item (not instance) to evade circular dependency. Assigned at bootstarp
348344
//debugger;
349345
//var ownerItem = <Item>this.Owner; - implemented IsAttachment on service object to remove dependency to Item object.
350-
if (isItem && this.owner.IsAttachment) { // ownerItem.IsAttachment) {
346+
if (isItem && (<Item>this.owner).IsAttachment) { // ownerItem.IsAttachment) {
351347
throw new ServiceObjectPropertyException(Strings.ItemAttachmentCannotBeUpdated, propertyDefinition);
352348
}
353349

src/js/Core/ServiceObjects/Folders/Folder.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ export class Folder extends ServiceObject {
455455
*
456456
* @return {ServiceObjectSchema} The schema associated with this type of object.
457457
*/
458-
GetSchema(): ServiceObjectSchema { return Schemas.FolderSchema; } //info: Schemas.FolderSchema is FolderSchema.Instance
458+
GetSchema(): ServiceObjectSchema { return Schemas.FolderSchema.Instance; }
459459

460460
/**
461461
* @internal Gets the name of the set field XML element.
@@ -655,10 +655,5 @@ export class Folder extends ServiceObject {
655655
if (this.PropertyBag.Contains(Schemas.FolderSchema.Permissions)) {
656656
this.Permissions.Validate();
657657
}
658-
}
659-
660-
/**
661-
* @internal ~~created this to help find serviceobject type, ServiceObjectInstance instanceof Item fails by creating circular dependency in javascript/typescript~~
662-
*/
663-
get InstanceType(): string { return XmlElementNames.Folder; }
658+
}
664659
}

src/js/Core/ServiceObjects/Items/Appointment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ export class Appointment extends Item implements ICalendarActionProvider {
716716
*
717717
* @return {ServiceObjectSchema} The schema associated with this type of object.
718718
*/
719-
GetSchema(): ServiceObjectSchema { return Schemas.AppointmentSchema; } //info: Schemas.AppointmentSchema is AppointmentSchema.Instance
719+
GetSchema(): ServiceObjectSchema { return Schemas.AppointmentSchema.Instance; }
720720

721721
/**
722722
* @internal Gets the element name of item in XML

src/js/Core/ServiceObjects/Items/Contact.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ export class Contact extends Item {
529529
*
530530
* @return {ServiceObjectSchema} The schema associated with this type of object.
531531
*/
532-
GetSchema(): ServiceObjectSchema { return Schemas.ContactSchema; } //info: Schemas.ContactSchema is ContactSchema.Instance
532+
GetSchema(): ServiceObjectSchema { return Schemas.ContactSchema.Instance; }
533533

534534
/**
535535
* @internal Gets the element name of item in XML

src/js/Core/ServiceObjects/Items/EmailMessage.ts

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,39 +37,39 @@ export class EmailMessage extends Item {
3737
get ToRecipients(): EmailAddressCollection {
3838
return <EmailAddressCollection>this.PropertyBag._getItem(Schemas.EmailMessageSchema.ToRecipients);
3939
}
40-
40+
4141
/**
4242
* Gets the list of Bcc recipients for the e-mail message.
4343
*
4444
*/
4545
get BccRecipients(): EmailAddressCollection {
4646
return <EmailAddressCollection>this.PropertyBag._getItem(Schemas.EmailMessageSchema.BccRecipients);
4747
}
48-
48+
4949
/**
5050
* Gets the list of Cc recipients for the e-mail message.
5151
*
5252
*/
5353
get CcRecipients(): EmailAddressCollection {
5454
return <EmailAddressCollection>this.PropertyBag._getItem(Schemas.EmailMessageSchema.CcRecipients);
5555
}
56-
56+
5757
/**
5858
* Gets the conversation topic of the e-mail message.
5959
*
6060
*/
6161
get ConversationTopic(): string {
6262
return <string>this.PropertyBag._getItem(Schemas.EmailMessageSchema.ConversationTopic);
6363
}
64-
64+
6565
/**
6666
* Gets the conversation index of the e-mail message.
6767
*
6868
*/
6969
get ConversationIndex(): number[] {
7070
return <number[]>this.PropertyBag._getItem(Schemas.EmailMessageSchema.ConversationIndex);
7171
}
72-
72+
7373
/**
7474
* Gets or sets the "on behalf" sender of the e-mail message.
7575
*
@@ -80,7 +80,7 @@ export class EmailMessage extends Item {
8080
set From(value: EmailAddress) {
8181
this.PropertyBag._setItem(Schemas.EmailMessageSchema.From, value);
8282
}
83-
83+
8484
/**
8585
* Gets or sets a value indicating whether this is an associated message.
8686
*
@@ -91,7 +91,7 @@ export class EmailMessage extends Item {
9191
set IsAssociated(value: boolean) {
9292
this.PropertyBag._setItem(Schemas.ItemSchema.IsAssociated, value);
9393
}
94-
94+
9595
/**
9696
* Gets or sets a value indicating whether a read receipt is requested for the e-mail message.
9797
*
@@ -102,7 +102,7 @@ export class EmailMessage extends Item {
102102
set IsDeliveryReceiptRequested(value: boolean) {
103103
this.PropertyBag._setItem(Schemas.EmailMessageSchema.IsDeliveryReceiptRequested, value);
104104
}
105-
105+
106106
/**
107107
* Gets or sets a value indicating whether the e-mail message is read.
108108
*
@@ -113,7 +113,7 @@ export class EmailMessage extends Item {
113113
set IsRead(value: boolean) {
114114
this.PropertyBag._setItem(Schemas.EmailMessageSchema.IsRead, value);
115115
}
116-
116+
117117
/**
118118
* Gets or sets a value indicating whether a read receipt is requested for the e-mail message.
119119
*
@@ -124,7 +124,7 @@ export class EmailMessage extends Item {
124124
set IsReadReceiptRequested(value: boolean) {
125125
this.PropertyBag._setItem(Schemas.EmailMessageSchema.IsReadReceiptRequested, value);
126126
}
127-
127+
128128
/**
129129
* Gets or sets a value indicating whether a response is requested for the e-mail message.
130130
*
@@ -135,15 +135,15 @@ export class EmailMessage extends Item {
135135
set IsResponseRequested(value: boolean) {
136136
this.PropertyBag._setItem(Schemas.EmailMessageSchema.IsResponseRequested, value);
137137
}
138-
138+
139139
/**
140140
* Gets the Internat Message Id of the e-mail message.
141141
*
142142
*/
143143
get InternetMessageId(): string {
144144
return <string>this.PropertyBag._getItem(Schemas.EmailMessageSchema.InternetMessageId);
145145
}
146-
146+
147147
/**
148148
* Gets or sets the references of the e-mail message.
149149
*
@@ -154,15 +154,15 @@ export class EmailMessage extends Item {
154154
set References(value: string) {
155155
this.PropertyBag._setItem(Schemas.EmailMessageSchema.References, value);
156156
}
157-
157+
158158
/**
159159
* Gets a list of e-mail addresses to which replies should be addressed.
160160
*
161161
*/
162162
get ReplyTo(): EmailAddressCollection {
163163
return <EmailAddressCollection>this.PropertyBag._getItem(Schemas.EmailMessageSchema.ReplyTo);
164164
}
165-
165+
166166
/**
167167
* Gets or sets the sender of the e-mail message.
168168
*
@@ -173,39 +173,39 @@ export class EmailMessage extends Item {
173173
set Sender(value: EmailAddress) {
174174
this.PropertyBag._setItem(Schemas.EmailMessageSchema.Sender, value);
175175
}
176-
176+
177177
/**
178178
* Gets the ReceivedBy property of the e-mail message.
179179
*
180180
*/
181181
get ReceivedBy(): EmailAddress {
182182
return <EmailAddress>this.PropertyBag._getItem(Schemas.EmailMessageSchema.ReceivedBy);
183183
}
184-
184+
185185
/**
186186
* Gets the ReceivedRepresenting property of the e-mail message.
187187
*
188188
*/
189189
get ReceivedRepresenting(): EmailAddress {
190190
return <EmailAddress>this.PropertyBag._getItem(Schemas.EmailMessageSchema.ReceivedRepresenting);
191191
}
192-
192+
193193
/**
194194
* Gets the ApprovalRequestData property of the e-mail message.
195195
*
196196
*/
197197
get ApprovalRequestData(): ApprovalRequestData {
198198
return <ApprovalRequestData>this.PropertyBag._getItem(Schemas.EmailMessageSchema.ApprovalRequestData);
199199
}
200-
200+
201201
/**
202202
* Gets the VotingInformation property of the e-mail message.
203203
*
204204
*/
205205
get VotingInformation(): VotingInformation {
206206
return <VotingInformation>this.PropertyBag._getItem(Schemas.EmailMessageSchema.VotingInformation);
207-
}
208-
207+
}
208+
209209
/**
210210
* Initializes an unsaved local instance of . To bind to an existing e-mail message, use EmailMessage.Bind() instead.
211211
*
@@ -243,7 +243,7 @@ export class EmailMessage extends Item {
243243
static Bind(service: ExchangeService, id: ItemId, propertySet: PropertySet = PropertySet.FirstClassProperties): IPromise<EmailMessage> {
244244
return service.BindToItem<EmailMessage>(id, propertySet, EmailMessage);
245245
}
246-
246+
247247
/**
248248
* Creates a forward response to the message.
249249
*
@@ -253,7 +253,7 @@ export class EmailMessage extends Item {
253253
this.ThrowIfThisIsNew();
254254
return new ResponseMessage(this, ResponseMessageType.Forward);
255255
}
256-
256+
257257
/**
258258
* Creates a reply response to the message.
259259
*
@@ -266,7 +266,7 @@ export class EmailMessage extends Item {
266266
this,
267267
replyAll ? ResponseMessageType.ReplyAll : ResponseMessageType.Reply);
268268
}
269-
269+
270270
//Forward(bodyPrefix: MessageBody, toRecipients: EmailAddress[]): IPromise<void> { throw new Error("EmailMessage.ts - Forward : Not implemented."); }
271271
//Forward(bodyPrefix: MessageBody, toRecipients: System.Collections.Generic.IEnumerable<T>): IPromise<void> { throw new Error("EmailMessage.ts - Forward : Not implemented."); }
272272
/**
@@ -283,28 +283,28 @@ export class EmailMessage extends Item {
283283

284284
return responseMessage.SendAndSaveCopy();
285285
}
286-
286+
287287
/**
288288
* @internal Gets the minimum required server version.
289289
*
290290
* @return {ExchangeVersion} Earliest Exchange version in which this service object type is supported.
291291
*/
292292
GetMinimumRequiredServerVersion(): ExchangeVersion { return ExchangeVersion.Exchange2007_SP1; }
293-
293+
294294
/**
295295
* @internal Internal method to return the schema associated with this type of object.
296296
*
297297
* @return {ServiceObjectSchema} The schema associated with this type of object.
298298
*/
299-
GetSchema(): ServiceObjectSchema { return Schemas.EmailMessageSchema; } //info: Schemas.EmailMessageSchema is EmailMessageSchema.Instance
300-
299+
GetSchema(): ServiceObjectSchema { return Schemas.EmailMessageSchema.Instance; }
300+
301301
/**
302302
* @internal Gets the element name of item in XML
303303
*
304304
* @return {string} name of elelment
305305
*/
306306
GetXmlElementName(): string { return XmlElementNames.Message; }
307-
307+
308308
/**
309309
* Send message.
310310
*
@@ -334,7 +334,7 @@ export class EmailMessage extends Item {
334334
else {
335335
// Regardless of whether item is dirty or not, if it has unprocessed
336336
// attachment changes, process them now.
337-
337+
338338
debugger; //todo: check - check for attachment save() promise.
339339
return PromiseFactory.resolve(
340340
// Validate and save attachments before sending.
@@ -353,7 +353,7 @@ export class EmailMessage extends Item {
353353
});
354354
}
355355
}
356-
356+
357357
/**
358358
* Replies to the message. Calling this method results in a call to EWS.
359359
*
@@ -367,12 +367,12 @@ export class EmailMessage extends Item {
367367

368368
return responseMessage.SendAndSaveCopy();
369369
}
370-
370+
371371
/**
372372
* Sends this e-mail message. Calling this method results in at least one call to EWS.
373373
*/
374374
Send(): IPromise<void> { return this.InternalSend(null, MessageDisposition.SendOnly); }
375-
375+
376376
/**
377377
* Sends this e-mail message and saves a copy of it in the Sent Items folder. SendAndSaveCopy does not work if the 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.
378378
*
@@ -404,7 +404,7 @@ export class EmailMessage extends Item {
404404
}
405405
return this.InternalSend(destinationFolderId, MessageDisposition.SendAndSaveCopy);
406406
}
407-
407+
408408
/**
409409
* Suppresses the read receipt on the message. Calling this method results in a call to EWS.
410410
*

src/js/Core/ServiceObjects/Items/Item.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ export class Item extends ServiceObject {
723723
*
724724
* @return {ServiceObjectSchema} The schema associated with this type of object.
725725
*/
726-
GetSchema(): ServiceObjectSchema { return Schemas.ItemSchema; } //info: Schemas.ItemSchema is ItemSchema.Instance;
726+
GetSchema(): ServiceObjectSchema { return Schemas.ItemSchema.Instance; }
727727

728728
/**
729729
* @internal Gets the element name of item in XML
@@ -1016,9 +1016,4 @@ export class Item extends ServiceObject {
10161016
}
10171017
}
10181018

1019-
/**
1020-
* @internal ~~created this to help find serviceobject type, ServiceObjectInstance instanceof Item fails by creating circular dependency in javascript/typescript~~
1021-
*/
1022-
get InstanceType(): string { return XmlElementNames.Item; }
1023-
10241019
}

0 commit comments

Comments
 (0)