/// <summary> /// Adds the schema property names to dictionary. /// </summary> /// <param name="type">The type.</param> /// <param name="propertyNameDictionary">The property name dictionary.</param> private static void AddSchemaPropertyNamesToDictionary(Type type, Dictionary <PropertyDefinition, string> propertyNameDictionary) { ServiceObjectSchema.ForeachPublicStaticPropertyFieldInType( type, delegate(PropertyDefinition propertyDefinition, FieldInfo fieldInfo) { propertyNameDictionary.Add(propertyDefinition, fieldInfo.Name); }); }
/// <summary> /// Initialize schema property names. /// </summary> internal static void InitializeSchemaPropertyNames() { lock (lockObject) { foreach (Type type in ServiceObjectSchema.allSchemaTypes.Member) { ServiceObjectSchema.ForeachPublicStaticPropertyFieldInType( type, delegate(PropertyDefinition propDef, FieldInfo fieldInfo) { propDef.Name = fieldInfo.Name; }); } } }
/// <summary> /// Adds schema properties to dictionary. /// </summary> /// <param name="type">Schema type.</param> /// <param name="propDefDictionary">The property definition dictionary.</param> internal static void AddSchemaPropertiesToDictionary( Type type, Dictionary <string, PropertyDefinitionBase> propDefDictionary) { ServiceObjectSchema.ForeachPublicStaticPropertyFieldInType( type, delegate(PropertyDefinition propertyDefinition, FieldInfo fieldInfo) { // Some property definitions descend from ServiceObjectPropertyDefinition but don't have // a Uri, like ExtendedProperties. Ignore them. if (!string.IsNullOrEmpty(propertyDefinition.Uri)) { PropertyDefinitionBase existingPropertyDefinition; if (propDefDictionary.TryGetValue(propertyDefinition.Uri, out existingPropertyDefinition)) { EwsUtilities.Assert( existingPropertyDefinition == propertyDefinition, "Schema.allSchemaProperties.delegate", string.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. List <PropertyDefinition> associatedInternalProperties = propertyDefinition.GetAssociatedInternalProperties(); foreach (PropertyDefinition associatedInternalProperty in associatedInternalProperties) { propDefDictionary.Add(associatedInternalProperty.Uri, associatedInternalProperty); } } } }); }