var XmlElementNames_1 = require("../../XmlElementNames");
var ComplexPropertyDefinition_1 = require("../../../PropertyDefinitions/ComplexPropertyDefinition");
var PropertyDefinitionFlags_1 = require("../../../Enumerations/PropertyDefinitionFlags");
var AltDictionary_1 = require("../../../AltDictionary");
var ExchangeVersion_1 = require("../../../Enumerations/ExchangeVersion");
var ExtendedPropertyCollection_1 = require("../../../ComplexProperties/ExtendedPropertyCollection");
var ServiceObjectSchema = (function () {
// private static lockObject: any = {};
// private static allSchemaTypes: LazyMember<string[]> = new LazyMember<string[]>(() => { //SchemaTypeList - LazyMember<T>; - using typenames[] temporarily
// var typeList: string[] = [];
// return typeList;
// typeList.push("AppointmentSchema");
// typeList.push("CalendarResponseObjectSchema");
// typeList.push("CancelMeetingMessageSchema");
// typeList.push("ContactGroupSchema");
// typeList.push("ContactSchema");
// typeList.push("ConversationSchema");
// typeList.push("EmailMessageSchema");
// typeList.push("FolderSchema");
// typeList.push("ItemSchema");
// typeList.push("MeetingMessageSchema");
// typeList.push("MeetingRequestSchema");
// typeList.push("MeetingCancellationSchema");
// typeList.push("MeetingResponseSchema");
// typeList.push("PostItemSchema");
// typeList.push("PostReplySchema");
// typeList.push("ResponseMessageSchema");
// typeList.push("ResponseObjectSchema");
// typeList.push("ServiceObjectSchema");
// typeList.push("SearchFolderSchema");
// typeList.push("TaskSchema");
//
// return typeList;
// });
//
//// private static allSchemaTypes: LazyMember<any[]> = new LazyMember<any[]>(() => { //SchemaTypeList - LazyMember<T>; - using typenames[] temporarily
//// var typeList: any[] = [];
//// return typeList;
//// typeList.push(AppointmentSchema);
//// typeList.push(CalendarResponseObjectSchema);
//// typeList.push(CancelMeetingMessageSchema);
//// typeList.push(ContactGroupSchema);
//// typeList.push(ContactSchema);
//// typeList.push(ConversationSchema);
//// typeList.push(EmailMessageSchema);
//// typeList.push(FolderSchema);
//// typeList.push(ItemSchema);
//// typeList.push(MeetingMessageSchema);
//// typeList.push(MeetingRequestSchema);
//// typeList.push(MeetingCancellationSchema);
//// typeList.push(MeetingResponseSchema);
//// typeList.push(PostItemSchema);
//// typeList.push(PostReplySchema);
//// typeList.push(ResponseMessageSchema);
//// typeList.push(ResponseObjectSchema);
//// typeList.push(ServiceObjectSchema);
//// typeList.push(SearchFolderSchema);
//// typeList.push(TaskSchema);
////
//// return typeList;
//// });
// private static allSchemaProperties = new LazyMember<StringPropertyDefinitionBaseDictionary<string, PropertyDefinitionBase>>(()=> {// string[] //LazyMember<T>;PropertyDefinitionDictionary => LazyMember<System.Collections.Generic.Dictionary<string, PropertyDefinitionBase>>;
// var propDefDictionary: StringPropertyDefinitionBaseDictionary<string, PropertyDefinitionBase> = new StringPropertyDefinitionBaseDictionary<string, PropertyDefinitionBase>();
// for (var type of ServiceObjectSchema.allSchemaTypes.Member) {
// //var type: string = item;
// ServiceObjectSchema.AddSchemaPropertiesToDictionary(type, propDefDictionary);
// }
//
// return propDefDictionary;
// });
// static AddSchemaPropertiesToDictionary(type: string /*System.Type*/, propDefDictionary: StringPropertyDefinitionBaseDictionary<string, PropertyDefinitionBase> /*System.Collections.Generic.Dictionary<TKey, TValue>*/): void {
// ServiceObjectSchema.ForeachPublicStaticPropertyFieldInType(
// type,
// (propertyDefinition: PropertyDefinition, fieldName: string) => {
// // Some property definitions descend from ServiceObjectPropertyDefinition but don't have
// // a Uri, like ExtendedProperties. Ignore them.
// if (!StringHelper.IsNullOrEmpty(propertyDefinition.Uri)) {
// var existingPropertyDefinition: IOutParam<PropertyDefinitionBase> = { outValue: null };
// if (propDefDictionary.tryGetValue(propertyDefinition.Uri, existingPropertyDefinition)) {
// EwsLogging.Assert(
// existingPropertyDefinition == propertyDefinition,
// "Schema.allSchemaProperties.delegate",
// StringHelper.Format("There are at least two distinct property definitions with the following URI: {0}", propertyDefinition.Uri));
// }
// else {
// propDefDictionary.add(propertyDefinition.Uri, propertyDefinition);
//
// // The following is a "generic hack" to register properties that are not public and
// // thus not returned by the above GetFields call. It is currently solely used to register
// // the MeetingTimeZone property.
// var associatedInternalProperties: PropertyDefinition[] = propertyDefinition.GetAssociatedInternalProperties();
//
// for (var associatedInternalProperty of associatedInternalProperties) {
// //var associatedInternalProperty: PropertyDefinition = item;
// propDefDictionary.add(associatedInternalProperty.Uri, associatedInternalProperty);
// }
// }
// }
// });
// }
// private static AddSchemaPropertyNamesToDictionary(type: string /*System.Type*/, propertyNameDictionary: PropDictionary<PropertyDefinition, string> /*System.Collections.Generic.Dictionary<TKey, TValue>*/): void {
// ServiceObjectSchema.ForeachPublicStaticPropertyFieldInType(
// type,
// (propertyDefinition: PropertyDefinition, fieldName: string) =>
// { propertyNameDictionary.add(propertyDefinition, fieldName); });
// }
// static FindPropertyDefinition(uri: string): PropertyDefinitionBase {
// return ServiceObjectSchema.allSchemaProperties.Member.get(uri);
// }
// static ForeachPublicStaticPropertyFieldInType(type: string /*System.Type*/, propFieldDelegate: (propertyDefinition: PropertyDefinition, fieldInfo: any /*FieldInfo*/) => void /*ServiceObjectSchema.PropertyFieldInfoDelegate*/): void {
//
// var keys = Object.keys(type);
// keys.forEach((s) => {
// if (typeof (type[s]) != "function" && type[s] instanceof (PropertyDefinition)) {
// var propertyDefinition = <PropertyDefinition> type[s];
// propFieldDelegate(propertyDefinition, s);
// }
// });
// //var staticfields = TypeSystem.GetObjectStaticPropertiesByClassName("Microsoft.Exchange.WebServices.Data." + type);
//
// //for (var field in staticfields) {
// // if (fieldInfo.FieldType == typeof (PropertyDefinition) || fieldInfo.FieldType.IsSubclassOf(typeof (PropertyDefinition))) {
// // PropertyDefinition propertyDefinition = (PropertyDefinition) fieldInfo.GetValue(null);
// // propFieldDelegate(propertyDefinition, fieldInfo);
// // }
// //}
// }
// static InitializeSchemaPropertyNames(): void {
//
// //lock(lockObject)
// //{
// for (var type of ServiceObjectSchema.allSchemaTypes.Member) {
// //var type: string = item;
// ServiceObjectSchema.ForeachPublicStaticPropertyFieldInType(
// type,
// (propDef: PropertyDefinition, fieldName: string) => { propDef.Name = fieldName; });
// }
// //}
// }
function ServiceObjectSchema() {
this.properties = new AltDictionary_1.Dictionary(function (key) { return key; }); // System.Collections.Generic.Dictionary<TKey, TValue>;
this.visibleProperties = []; //System.Collections.Generic.List<PropertyDefinition>;
this.firstClassProperties = []; //System.Collections.Generic.List<PropertyDefinition>;
this.firstClassSummaryProperties = []; //System.Collections.Generic.List<PropertyDefinition>;
this.indexedProperties = []; //System.Collections.Generic.List<IndexedPropertyDefinition>;
this.RegisterProperties();
}
Object.defineProperty(ServiceObjectSchema.prototype, "FirstClassProperties", {
//todo: fixing difficulties with following c# code.
//using PropertyDefinitionDictionary = LazyMember < System.Collections.Generic.Dictionary<string, PropertyDefinitionBase>>;
//type SchemaTypeList = LazyMember <string[]>;
get: function () { return this.firstClassProperties; } //System.Collections.Generic.List<PropertyDefinition>;
,
enumerable: true,
configurable: true
});
Object.defineProperty(ServiceObjectSchema.prototype, "FirstClassSummaryProperties", {
get: function () { return this.firstClassSummaryProperties; } //System.Collections.Generic.List<PropertyDefinition>;
,
enumerable: true,
configurable: true
});
Object.defineProperty(ServiceObjectSchema.prototype, "IndexedProperties", {
get: function () { return this.indexedProperties; } //System.Collections.Generic.List<IndexedPropertyDefinition>;
,
enumerable: true,
configurable: true
});
ServiceObjectSchema.prototype.GetEnumerator = function () { return this.visibleProperties; };
ServiceObjectSchema.prototype.RegisterIndexedProperty = function (indexedProperty) { this.indexedProperties.push(indexedProperty); };
ServiceObjectSchema.prototype.RegisterInternalProperty = function (property) { this.RegisterProperty(property, true); };
ServiceObjectSchema.prototype.RegisterProperties = function () { };
//RegisterProperty(property: PropertyDefinition): any { throw new Error("ServiceObjectSchema.ts - RegisterProperty : Not implemented."); }
ServiceObjectSchema.prototype.RegisterProperty = function (property, isInternal) {
if (isInternal === void 0) { isInternal = false; }
this.properties.Add(property.XmlElementName, property);
if (!isInternal) {
this.visibleProperties.push(property);
}
// If this property does not have to be requested explicitly, add
// it to the list of firstClassProperties.
if (!property.HasFlag(PropertyDefinitionFlags_1.PropertyDefinitionFlags.MustBeExplicitlyLoaded)) {
this.firstClassProperties.push(property);
}
// If this property can be found, add it to the list of firstClassSummaryProperties
if (property.HasFlag(PropertyDefinitionFlags_1.PropertyDefinitionFlags.CanFind)) {
this.firstClassSummaryProperties.push(property);
}
};
ServiceObjectSchema.prototype.TryGetPropertyDefinition = function (xmlElementName, propertyDefinition) {
return this.properties.tryGetValue(xmlElementName, propertyDefinition);
};
//static appointmentSchema: AppointmentSchema;
ServiceObjectSchema.ExtendedProperties = new ComplexPropertyDefinition_1.ComplexPropertyDefinition("ExtendedProperties", XmlElementNames_1.XmlElementNames.ExtendedProperty, ExchangeVersion_1.ExchangeVersion.Exchange2007_SP1, null, PropertyDefinitionFlags_1.PropertyDefinitionFlags.AutoInstantiateOnRead | PropertyDefinitionFlags_1.PropertyDefinitionFlags.ReuseInstance | PropertyDefinitionFlags_1.PropertyDefinitionFlags.CanSet | PropertyDefinitionFlags_1.PropertyDefinitionFlags.CanUpdate, function () { return new ExtendedPropertyCollection_1.ExtendedPropertyCollection(); });
return ServiceObjectSchema;
})();
exports.ServiceObjectSchema = ServiceObjectSchema;