Option name | Type | Description |
---|---|---|
service | ExchangeService | EWS service to which this object belongs. |
Internal constructor.
function ServiceObject(service) {
//EwsUtilities.ValidateParam(service, "service");
//EwsUtilities.ValidateServiceObjectVersion(this, service.RequestedServerVersion);
this.lockObject = {};
Defines an event that is triggered when the service object changes.
this.OnChange = [];
this.Service = service;
this.propertyBag = new PropertyBag_1.PropertyBag(this);
}
Object.defineProperty(ServiceObject.prototype, "PropertyBag", {
The property bag holding property values for this object.
get: function () { return this.propertyBag; },
enumerable: true,
configurable: true
});
Object.defineProperty(ServiceObject.prototype, "Schema", {
Gets the schema associated with this type of object.
get: function () { return this.GetSchema(); },
enumerable: true,
configurable: true
});
Object.defineProperty(ServiceObject.prototype, "IsNew", {
Indicates whether this object is a real store item, or if it's a local object that has yet to be saved.
get: function () {
var id = this.GetId();
return id == null ? true : !id.IsValid;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ServiceObject.prototype, "IsDirty", {
Gets a value indicating whether the object has been modified and should be saved.
get: function () {
return this.PropertyBag.IsDirty;
},
enumerable: true,
configurable: true
});
Option name | Type | Description |
---|---|---|
propertyDefinition | PropertyDefinitionBase | Definition of the property to get. |
Gets the value of specified property in this instance.
This Indexer of c#
ServiceObject.prototype._getItem = function (propertyDefinition) {
var propertyValue;
var propDef = propertyDefinition;
if (propDef != null) {
//todo: check for propertydefinitionbase type or child type;
return this.PropertyBag._getItem(propDef);
}
else {
var extendedPropDef = propertyDefinition;
if (extendedPropDef != null) {
if (this.TryGetExtendedProperty(extendedPropDef, propertyValue)) {
return propertyValue;
}
else {
throw new ServiceObjectPropertyException_1.ServiceObjectPropertyException(Strings_1.Strings.MustLoadOrAssignPropertyBeforeAccess, propertyDefinition);
}
}
else {
// Other subclasses of PropertyDefinitionBase are not supported.
throw new Error(ExtensionMethods_1.StringHelper.Format("not supported for property definition type: {0}", propertyDefinition.constructor));
}
}
};
Triggers dispatch of the change event.
ServiceObject.prototype.Changed = function () {
if (this.OnChange != null) {
for (var _i = 0, _a = this.OnChange; _i < _a.length; _i++) {
var changeDelegate = _a[_i];
changeDelegate(this);
}
}
};
Clears the object's change log.
ServiceObject.prototype.ClearChangeLog = function () { this.PropertyBag.ClearChangeLog(); };
Gets the name of the change XML element.
ServiceObject.prototype.GetChangeXmlElementName = function () { return XmlElementNames_1.XmlElementNames.ItemChange; };
Gets the name of the delete field XML element.
ServiceObject.prototype.GetDeleteFieldXmlElementName = function () { return XmlElementNames_1.XmlElementNames.DeleteItemField; };
Gets the extended properties collection.
ServiceObject.prototype.GetExtendedProperties = function () { return null; };
The unique Id of this object.
ServiceObject.prototype.GetId = function () {
var idPropertyDefinition = this.GetIdPropertyDefinition();
var serviceId = { outValue: null };
if (idPropertyDefinition != null) {
this.PropertyBag.TryGetValue(idPropertyDefinition, serviceId);
}
return serviceId.outValue;
};
The property definition for the Id of this object.
ServiceObject.prototype.GetIdPropertyDefinition = function () { return null; };
Determines whether properties defined with ScopedDateTimePropertyDefinition require custom time zone scoping.
ServiceObject.prototype.GetIsCustomDateTimeScopingRequired = function () { return false; };
Option name | Type | Description |
---|---|---|
isUpdateOperation | boolean | Indicates whether the operation being petrformed is an update operation. |
return | boolean | true if a time zone SOAP header should be emitted; otherwise, false. |
Gets a value indicating whether a time zone SOAP header should be emitted in a CreateItem or UpdateItem request so this item can be property saved or updated.
ServiceObject.prototype.GetIsTimeZoneHeaderRequired = function (isUpdateOperation) { return false; };
Gets the collection of loaded property definitions.
ServiceObject.prototype.GetLoadedPropertyDefinitions = function () {
var propDefs = [];
for (var _i = 0, _a = this.PropertyBag.Properties.Keys; _i < _a.length; _i++) {
var propDef = _a[_i];
propDefs.push(propDef);
}
if (this.GetExtendedProperties() != null) {
for (var _b = 0, _c = this.GetExtendedProperties().Items; _b < _c.length; _b++) {
var extProp = _c[_b];
propDefs.push(extProp.PropertyDefinition);
}
}
return propDefs;
};
Gets the minimum required server version.
ServiceObject.prototype.GetMinimumRequiredServerVersion = function () { throw new Error("abstract method, must implement"); };
Internal method to return the schema associated with this type of object.
ServiceObject.prototype.GetSchema = function () { throw new Error("abstract method, must implement"); };
Gets the name of the set field XML element.
ServiceObject.prototype.GetSetFieldXmlElementName = function () { return XmlElementNames_1.XmlElementNames.SetItemField; };
GetXmlElementName retrieves the XmlElementName of this type based on the EwsObjectDefinition attribute that decorates it, if present.
ServiceObject.prototype.GetXmlElementName = function () {
throw new Error("ServiceObject.ts - GetXmlElementName - this must be overridden by derived class - can not use reflection to get class attribute in javascript");
if (ExtensionMethods_1.StringHelper.IsNullOrEmpty(this.xmlElementName)) {
this.xmlElementName = this.GetXmlElementNameOverride();
EwsLogging_1.EwsLogging.Assert(!ExtensionMethods_1.StringHelper.IsNullOrEmpty(this.xmlElementName), "EwsObject.GetXmlElementName", ExtensionMethods_1.StringHelper.Format("The class {0} does not have an associated XML element name.", "unknown decendent of ServiceObject - in serviceObject.GetXmlElementname"));
}
return this.xmlElementName;
};
This methods lets subclasses of ServiceObject override the default mechanism by which the XML element name associated with their type is retrieved.
ServiceObject.prototype.GetXmlElementNameOverride = function () { return null; };
Option name | Type | Description |
---|---|---|
deleteMode | DeleteMode | The deletion mode. |
sendCancellationsMode | SendCancellationsMode | Indicates whether meeting cancellation messages should be sent. |
affectedTaskOccurrences | AffectedTaskOccurrence | Indicate which occurrence of a recurring task should be deleted. |
Deletes the object.
ServiceObject.prototype.InternalDelete = function (deleteMode, sendCancellationsMode, affectedTaskOccurrences) {
throw new Error("abstract method, must implement");
};
Option name | Type | Description |
---|---|---|
propertySet | PropertySet | The properties to load. |
Loads the specified set of properties on the object.
ServiceObject.prototype.InternalLoad = function (propertySet) { throw new Error("abstract method, must implement"); };
ServiceObject.prototype.Load = function (propertySet) {
return this.InternalLoad(propertySet || PropertySet_1.PropertySet.FirstClassProperties);
};
//LoadFromJson(jsonObject: JsonObject, service: ExchangeService, clearPropertyBag: boolean): any { throw new Error("ServiceObject.ts - LoadFromJson : Not implemented."); }
//LoadFromJson(jsonServiceObject: JsonObject, service: ExchangeService, clearPropertyBag: boolean, requestedPropertySet: PropertySet, summaryPropertiesOnly: boolean): any { throw new Error("ServiceObject.ts - LoadFromJson : Not implemented."); }
Option name | Type | Description |
---|---|---|
jsObject | any | Jason Object converted from XML. |
service | ExchangeService | The service. |
clearPropertyBag | boolean | if set to true [clear property bag]. |
requestedPropertySet | PropertySet | The property set. |
summaryPropertiesOnly | boolean | if set to true [summary props only]. |
Loads service object from XML.
ServiceObject.prototype.LoadFromXmlJsObject = function (jsObject, service, clearPropertyBag, requestedPropertySet, summaryPropertiesOnly) {
if (requestedPropertySet === void 0) { requestedPropertySet = null; }
if (summaryPropertiesOnly === void 0) { summaryPropertiesOnly = false; }
this.PropertyBag.LoadFromXmlJsObject(jsObject, service, clearPropertyBag, requestedPropertySet, summaryPropertiesOnly);
};
Throws exception if this is a new service object.
ServiceObject.prototype.ThrowIfThisIsNew = function () {
if (this.IsNew) {
throw new Error("service object does not have id"); //InvalidOperationException(Strings.ServiceObjectDoesNotHaveId);
}
};
Throws exception if this is not a new service object.
ServiceObject.prototype.ThrowIfThisIsNotNew = function () {
if (!this.IsNew) {
throw new Error("service object already have id"); //InvalidOperationException(Strings.ServiceObjectAlreadyHasId);
}
};
//ToJson(service: ExchangeService, isUpdateOperation: boolean): any { return this.PropertyBag.ToJson(service, isUpdateOperation);}
Option name | Type | Description |
---|---|---|
propertyDefinition | ExtendedPropertyDefinition | The property definition. |
propertyValue | IOutParam.<T> | The property value. |
return | boolean | True if property retrieved, false otherwise. |
Try to get the value of a specified extended property in this instance.
ServiceObject.prototype.TryGetExtendedProperty = function (propertyDefinition, propertyValue) {
var propertyCollection = this.GetExtendedProperties();
if ((propertyCollection != null) &&
propertyCollection.TryGetValue(propertyDefinition, propertyValue)) {
return true;
}
else {
propertyValue.outValue = null; //default(T);
return false;
}
};
//todo:fix - implement type casting on specific type request version.
//TryGetProperty<T>(propertyDefinition: PropertyDefinitionBase, propertyValue: any): boolean { throw new Error("Need implementation."); }
//TryGetProperty(propertyDefinition: PropertyDefinitionBase, propertyValue: any): boolean { throw new Error("ServiceObject.ts - TryGetProperty : Not implemented."); }
Option name | Type | Description |
---|---|---|
propertyDefinition | PropertyDefinitionBase | The property definition. |
propertyValue | IOutParam.<T> | The property value. |
return | boolean | True if property retrieved, false otherwise. |
Try to get the value of a specified property in this instance.
ServiceObject.prototype.TryGetProperty = function (propertyDefinition, propertyValue) {
var propDef = propertyDefinition; // as PropertyDefinition;
debugger; //todo: fix for compatibility checking, if this is propertydefinition or propertydefinitionbase
if (propDef != null) {
return this.PropertyBag.TryGetPropertyAs(propDef, propertyValue);
}
else {
debugger; //todo: check for compatibility of extendedpropertydefition or propertydefition.
var extPropDef = propertyDefinition; // as ExtendedPropertyDefinition;
if (extPropDef != null) {
return this.TryGetExtendedProperty(extPropDef, propertyValue);
}
else {
// Other subclasses of PropertyDefinitionBase are not supported.
throw new Error(ExtensionMethods_1.StringHelper.Format(Strings_1.Strings.OperationNotSupportedForPropertyDefinitionType, propertyDefinition.Type)); //NotSupportedException
}
}
};
Validates this instance.
ServiceObject.prototype.Validate = function () { this.PropertyBag.Validate(); };
//WriteToJsonForUpdate(service: ExchangeService): any { throw new Error("ServiceObject.ts - WriteToJsonForUpdate : Not implemented."); }
Option name | Type | Description |
---|---|---|
writer | EwsServiceXmlWriter | The writer. |
Writes service object as XML.
ServiceObject.prototype.WriteToXml = function (writer) { this.PropertyBag.WriteToXml(writer); };
Option name | Type | Description |
---|---|---|
writer | EwsServiceXmlWriter | The writer. |
Writes service object for update as XML.
ServiceObject.prototype.WriteToXmlForUpdate = function (writer) { this.PropertyBag.WriteToXmlForUpdate(writer); };
Object.defineProperty(ServiceObject.prototype, "InstanceType", {
created this to help find serviceobject type, ServiceObjectInstance instanceof Item/Folder/Attachment fails by creating circular dependency in javascript/typescript
get: function () { return "ServiceObject"; },
enumerable: true,
configurable: true
});
Object.defineProperty(ServiceObject.prototype, "IsAttachment", {
created this to keep item and folder object away from here. modularization would fail and create a larger file
get: function () { return false; } //only item instance would return true.
,
enumerable: true,
configurable: true
});
return ServiceObject;
})();
exports.ServiceObject = ServiceObject;