/// <summary> /// Gets the value of specified property in this instance. /// </summary> /// <param name="propertyDefinition">Definition of the property to get.</param> /// <exception cref="ServiceVersionException">Raised if this property requires a later version of Exchange.</exception> /// <exception cref="PropertyException">Raised if this property hasn't been assigned or loaded. Raised for set if property cannot be updated or deleted.</exception> public object this[PropertyDefinitionBase propertyDefinition] { get { object propertyValue; PropertyDefinition propDef = propertyDefinition as PropertyDefinition; if (propDef != null) { return(this.PropertyBag[propDef]); } else { ExtendedPropertyDefinition extendedPropDef = propertyDefinition as ExtendedPropertyDefinition; if (extendedPropDef != null) { if (this.TryGetExtendedProperty(extendedPropDef, out propertyValue)) { return(propertyValue); } else { throw new ServiceObjectPropertyException(Strings.MustLoadOrAssignPropertyBeforeAccess, propertyDefinition); } } else { // Other subclasses of PropertyDefinitionBase are not supported. throw new NotSupportedException(string.Format( Strings.OperationNotSupportedForPropertyDefinitionType, propertyDefinition.GetType().Name)); } } } }
/// <summary> /// Tries to read element from XML. /// </summary> /// <param name="reader">The reader.</param> /// <returns>True if element was read.</returns> internal override bool TryReadElementFromXml(EwsServiceXmlReader reader) { bool result = base.TryReadElementFromXml(reader); if (!result) { if (reader.LocalName == XmlElementNames.FieldURIOrConstant) { reader.Read(); reader.EnsureCurrentNodeIsStartElement(); if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Constant)) { this.value = reader.ReadAttributeValue(XmlAttributeNames.Value); result = true; } else { result = PropertyDefinitionBase.TryLoadFromXml(reader, ref this.otherPropertyDefinition); } } } return(result); }
/// <summary> /// Tries to load from XML. /// </summary> /// <param name="reader">The reader.</param> /// <param name="propertyDefinition">The property definition.</param> /// <returns>True if property was loaded.</returns> internal static bool TryLoadFromXml(EwsServiceXmlReader reader, ref PropertyDefinitionBase propertyDefinition) { switch (reader.LocalName) { case XmlElementNames.FieldURI: propertyDefinition = ServiceObjectSchema.FindPropertyDefinition(reader.ReadAttributeValue(XmlAttributeNames.FieldURI)); reader.SkipCurrentElement(); return(true); case XmlElementNames.IndexedFieldURI: propertyDefinition = new IndexedPropertyDefinition( reader.ReadAttributeValue(XmlAttributeNames.FieldURI), reader.ReadAttributeValue(XmlAttributeNames.FieldIndex)); reader.SkipCurrentElement(); return(true); case XmlElementNames.ExtendedFieldURI: propertyDefinition = new ExtendedPropertyDefinition(); (propertyDefinition as ExtendedPropertyDefinition).LoadFromXml(reader); return(true); default: return(false); } }
/// <summary> /// Validate request. /// </summary> internal override void Validate() { base.Validate(); if (this.SearchQueries == null || this.SearchQueries.Count == 0) { throw new ServiceValidationException(Strings.MailboxQueriesParameterIsNotSpecified); } foreach (MailboxQuery searchQuery in this.SearchQueries) { if (searchQuery.MailboxSearchScopes == null || searchQuery.MailboxSearchScopes.Length == 0) { throw new ServiceValidationException(Strings.MailboxQueriesParameterIsNotSpecified); } } if (!string.IsNullOrEmpty(this.SortByProperty)) { PropertyDefinitionBase prop = null; try { prop = ServiceObjectSchema.FindPropertyDefinition(this.SortByProperty); } catch (KeyNotFoundException) { } if (prop == null) { throw new ServiceValidationException(string.Format(Strings.InvalidSortByPropertyForMailboxSearch, this.SortByProperty)); } } }
/// <summary> /// ServiceObjectPropertyException Constructor. /// </summary> /// <param name="message">Error message text.</param> /// <param name="propertyDefinition">The definition of the property that is at the origin of the exception.</param> /// <param name="innerException">Inner exception.</param> public ServiceObjectPropertyException( string message, PropertyDefinitionBase propertyDefinition, Exception innerException) : base(message, propertyDefinition.GetPrintableName(), innerException) { this.propertyDefinition = propertyDefinition; }
/// <summary> /// Adds the specified property definition / sort direction pair to the collection. /// </summary> /// <param name="propertyDefinition">The property definition.</param> /// <param name="sortDirection">The sort direction.</param> public void Add(PropertyDefinitionBase propertyDefinition, SortDirection sortDirection) { if (this.Contains(propertyDefinition)) { throw new ServiceLocalException(string.Format(Strings.PropertyAlreadyExistsInOrderByCollection, propertyDefinition.GetPrintableName())); } this.propDefSortOrderPairList.Add(new PropertyDefinitionSortDirectionPair(propertyDefinition, sortDirection)); }
/// <summary> /// Creates the json delete update. /// </summary> /// <param name="propertyDefinition">The property definition.</param> /// <param name="service">The service.</param> /// <param name="serviceObject">The service object.</param> /// <returns></returns> internal static JsonObject CreateJsonDeleteUpdate(PropertyDefinitionBase propertyDefinition, ExchangeService service, ServiceObject serviceObject) { JsonObject jsonUpdate = new JsonObject(); jsonUpdate.AddTypeParameter(serviceObject.GetDeleteFieldXmlElementName()); jsonUpdate.Add("PropertyPath", (propertyDefinition as IJsonSerializable).ToJson(service)); return(jsonUpdate); }
/// <summary> /// Validate request. /// </summary> internal override void Validate() { base.Validate(); if (this.SearchQueries == null || this.SearchQueries.Count == 0) { throw new ServiceValidationException(Strings.MailboxQueriesParameterIsNotSpecified); } foreach (MailboxQuery searchQuery in this.SearchQueries) { if (searchQuery.MailboxSearchScopes == null || searchQuery.MailboxSearchScopes.Length == 0) { throw new ServiceValidationException(Strings.MailboxQueriesParameterIsNotSpecified); } foreach (MailboxSearchScope searchScope in searchQuery.MailboxSearchScopes) { if (searchScope.ExtendedAttributes != null && searchScope.ExtendedAttributes.Count > 0 && !DiscoverySchemaChanges.SearchMailboxesExtendedData.IsCompatible(this)) { throw new ServiceVersionException( string.Format( Strings.ClassIncompatibleWithRequestVersion, typeof(ExtendedAttribute).Name, DiscoverySchemaChanges.SearchMailboxesExtendedData.MinimumServerVersion)); } if (searchScope.SearchScopeType != MailboxSearchScopeType.LegacyExchangeDN && (!DiscoverySchemaChanges.SearchMailboxesExtendedData.IsCompatible(this) || !DiscoverySchemaChanges.SearchMailboxesAdditionalSearchScopes.IsCompatible(this))) { throw new ServiceVersionException( string.Format( Strings.EnumValueIncompatibleWithRequestVersion, searchScope.SearchScopeType.ToString(), typeof(MailboxSearchScopeType).Name, DiscoverySchemaChanges.SearchMailboxesAdditionalSearchScopes.MinimumServerVersion)); } } } if (!string.IsNullOrEmpty(this.SortByProperty)) { PropertyDefinitionBase prop = null; try { prop = ServiceObjectSchema.FindPropertyDefinition(this.SortByProperty); } catch (KeyNotFoundException) { } if (prop == null) { throw new ServiceValidationException(string.Format(Strings.InvalidSortByPropertyForMailboxSearch, this.SortByProperty)); } } }
/// <summary> /// Initializes a new instance of the <see cref="ContainsSubstring"/> class. /// </summary> /// <param name="propertyDefinition">The definition of the property that is being compared. Property definitions are available as static members from schema classes (for example, EmailMessageSchema.Subject, AppointmentSchema.Start, ContactSchema.GivenName, etc.)</param> /// <param name="value">The value to compare with.</param> /// <param name="containmentMode">The containment mode.</param> /// <param name="comparisonMode">The comparison mode.</param> public ContainsSubstring( PropertyDefinitionBase propertyDefinition, string value, ContainmentMode containmentMode, ComparisonMode comparisonMode) : this(propertyDefinition, value) { this.containmentMode = containmentMode; this.comparisonMode = comparisonMode; }
/// <summary> /// Tries to get the value for a property definition in the collection. /// </summary> /// <param name="propertyDefinition">The property definition.</param> /// <param name="sortDirection">The sort direction.</param> /// <returns>True if collection contains property definition, otherwise false.</returns> public bool TryGetValue(PropertyDefinitionBase propertyDefinition, out SortDirection sortDirection) { foreach (PropertyDefinitionSortDirectionPair pair in this.propDefSortOrderPairList) { if (pair.Value.Equals(propertyDefinition)) { sortDirection = pair.Value; return(true); } } sortDirection = SortDirection.Ascending; // out parameter has to be set to some value. return(false); }
/// <summary> /// Loads from json. /// </summary> /// <param name="jsonProperty">The json property.</param> /// <param name="service">The service.</param> internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service) { base.LoadFromJson(jsonProperty, service); JsonObject jsonFieldUriOrConstant = jsonProperty.ReadAsJsonObject(XmlElementNames.FieldURIOrConstant).ReadAsJsonObject(XmlElementNames.Item); if (jsonFieldUriOrConstant.ReadTypeString() == XmlElementNames.Constant) { this.value = jsonFieldUriOrConstant[XmlElementNames.Value]; } else { this.otherPropertyDefinition = PropertyDefinitionBase.TryLoadFromJson(jsonProperty); } }
/// <summary> /// Initializes a new instance of the <see cref="Grouping"/> class. /// </summary> /// <param name="groupOn">The property to group on.</param> /// <param name="sortDirection">The sort direction.</param> /// <param name="aggregateOn">The property to aggregate on.</param> /// <param name="aggregateType">The type of aggregate to calculate.</param> public Grouping( PropertyDefinitionBase groupOn, SortDirection sortDirection, PropertyDefinitionBase aggregateOn, AggregateType aggregateType) : this() { EwsUtilities.ValidateParam(groupOn, "groupOn"); EwsUtilities.ValidateParam(aggregateOn, "aggregateOn"); this.groupOn = groupOn; this.sortDirection = sortDirection; this.aggregateOn = aggregateOn; this.aggregateType = aggregateType; }
/// <summary> /// Tries to load from XML. /// </summary> /// <param name="reader">The reader.</param> /// <param name="propertyDefinition">The property definition.</param> /// <returns>True if property was loaded.</returns> internal static bool TryLoadFromXml(EwsServiceXmlReader reader, ref PropertyDefinitionBase propertyDefinition) { switch (reader.LocalName) { case XmlElementNames.FieldURI: propertyDefinition = ServiceObjectSchema.FindPropertyDefinition(reader.ReadAttributeValue(XmlAttributeNames.FieldURI)); reader.SkipCurrentElement(); return true; case XmlElementNames.IndexedFieldURI: propertyDefinition = new IndexedPropertyDefinition( reader.ReadAttributeValue(XmlAttributeNames.FieldURI), reader.ReadAttributeValue(XmlAttributeNames.FieldIndex)); reader.SkipCurrentElement(); return true; case XmlElementNames.ExtendedFieldURI: propertyDefinition = new ExtendedPropertyDefinition(); (propertyDefinition as ExtendedPropertyDefinition).LoadFromXml(reader); return true; default: return false; } }
/// <summary> /// Try to get the value of a specified property in this instance. /// </summary> /// <param name="propertyDefinition">The property definition.</param> /// <param name="propertyValue">The property value.</param> /// <typeparam name="T">Type of expected property value.</typeparam> /// <returns>True if property retrieved, false otherwise.</returns> public bool TryGetProperty <T>(PropertyDefinitionBase propertyDefinition, out T propertyValue) { PropertyDefinition propDef = propertyDefinition as PropertyDefinition; if (propDef != null) { return(this.PropertyBag.TryGetProperty <T>(propDef, out propertyValue)); } else { ExtendedPropertyDefinition extPropDef = propertyDefinition as ExtendedPropertyDefinition; if (extPropDef != null) { return(this.TryGetExtendedProperty <T>(extPropDef, out propertyValue)); } else { // Other subclasses of PropertyDefinitionBase are not supported. throw new NotSupportedException(string.Format( Strings.OperationNotSupportedForPropertyDefinitionType, propertyDefinition.GetType().Name)); } } }
/// <summary> /// Initializes a new instance of the <see cref="IsEqualTo"/> class. /// </summary> /// <param name="propertyDefinition">The definition of the property that is being compared. Property definitions are available as static members from schema classes (for example, EmailMessageSchema.Subject, AppointmentSchema.Start, ContactSchema.GivenName, etc.)</param> /// <param name="otherPropertyDefinition">The definition of the property to compare with. Property definitions are available on schema classes (EmailMessageSchema, AppointmentSchema, etc.)</param> public IsEqualTo(PropertyDefinitionBase propertyDefinition, PropertyDefinitionBase otherPropertyDefinition) : base(propertyDefinition, otherPropertyDefinition) { }
/// <summary> /// Initializes a new instance of the <see cref="T:Microsoft.Exchange.WebServices.Data.ServiceObjectPropertyException"/> class with serialized data. /// </summary> /// <param name="info">The object that holds the serialized object data.</param> /// <param name="context">The contextual information about the source or destination.</param> protected ServiceObjectPropertyException(SerializationInfo info, StreamingContext context) : base(info, context) { this.propertyDefinition = (PropertyDefinitionBase)info.GetValue("PropertyDefinition", typeof(PropertyDefinitionBase)); }
/// <summary> /// Try to get the value of a specified property in this instance. /// </summary> /// <param name="propertyDefinition">The property definition.</param> /// <param name="propertyValue">The property value.</param> /// <returns>True if property retrieved, false otherwise.</returns> public bool TryGetProperty(PropertyDefinitionBase propertyDefinition, out object propertyValue) { return(this.TryGetProperty <object>(propertyDefinition, out propertyValue)); }
/// <summary> /// Initializes a new instance of the <see cref="PropertyBasedFilter"/> class. /// </summary> /// <param name="propertyDefinition">The property definition.</param> internal PropertyBasedFilter(PropertyDefinitionBase propertyDefinition) : base() { this.propertyDefinition = propertyDefinition; }
/// <summary> /// Loads from json. /// </summary> /// <param name="jsonProperty">The json property.</param> /// <param name="service">The service.</param> internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service) { this.PropertyDefinition = PropertyDefinitionBase.TryLoadFromJson(jsonProperty.ReadAsJsonObject(XmlElementNames.Item)); }
/// <summary> /// Initializes a new instance of the <see cref="RelationalFilter"/> class. /// </summary> /// <param name="propertyDefinition">The definition of the property that is being compared. Property definitions are available as static members from schema classes (for example, EmailMessageSchema.Subject, AppointmentSchema.Start, ContactSchema.GivenName, etc.)</param> /// <param name="otherPropertyDefinition">The definition of the property to compare with. Property definitions are available as static members from schema classes (for example, EmailMessageSchema, AppointmentSchema, etc.)</param> internal RelationalFilter(PropertyDefinitionBase propertyDefinition, PropertyDefinitionBase otherPropertyDefinition) : base(propertyDefinition) { this.otherPropertyDefinition = otherPropertyDefinition; }
/// <summary> /// Initializes a new instance of the <see cref="IsGreaterThanOrEqualTo"/> class. /// </summary> /// <param name="propertyDefinition">The definition of the property that is being compared. Property definitions are available as static members from schema classes (for example, EmailMessageSchema.Subject, AppointmentSchema.Start, ContactSchema.GivenName, etc.)</param> /// <param name="otherPropertyDefinition">The definition of the property to compare with. Property definitions are available on schema classes (EmailMessageSchema, AppointmentSchema, etc.)</param> public IsGreaterThanOrEqualTo(PropertyDefinitionBase propertyDefinition, PropertyDefinitionBase otherPropertyDefinition) : base(propertyDefinition, otherPropertyDefinition) { }
/// <summary> /// ServiceObjectPropertyException constructor. /// </summary> /// <param name="propertyDefinition">The definition of the property that is at the origin of the exception.</param> public ServiceObjectPropertyException(PropertyDefinitionBase propertyDefinition) : base(propertyDefinition.GetPrintableName()) { this.propertyDefinition = propertyDefinition; }
/// <summary> /// Initializes a new instance of the <see cref="ContainsSubstring"/> class. /// The ContainmentMode property is initialized to ContainmentMode.Substring, and /// the ComparisonMode property is initialized to ComparisonMode.IgnoreCase. /// </summary> /// <param name="propertyDefinition">The definition of the property that is being compared. Property definitions are available as static members from schema classes (for example, EmailMessageSchema.Subject, AppointmentSchema.Start, ContactSchema.GivenName, etc.)</param> /// <param name="value">The value to compare with.</param> public ContainsSubstring(PropertyDefinitionBase propertyDefinition, string value) : base(propertyDefinition) { this.value = value; }
/// <summary> /// Initializes a new instance of the <see cref="IsLessThan"/> class. /// </summary> /// <param name="propertyDefinition">The definition of the property that is being compared. Property definitions are available as static members from schema classes (for example, EmailMessageSchema.Subject, AppointmentSchema.Start, ContactSchema.GivenName, etc.)</param> /// <param name="value">The value to compare the property with.</param> public IsLessThan(PropertyDefinitionBase propertyDefinition, object value) : base(propertyDefinition, value) { }
/// <summary> /// Initializes a new instance of the <see cref="ExcludesBitmask"/> class. /// </summary> /// <param name="propertyDefinition">The definition of the property that is being compared. Property definitions are available as static members from schema classes (for example, EmailMessageSchema.Subject, AppointmentSchema.Start, ContactSchema.GivenName, etc.)</param> /// <param name="bitmask">The bitmask to compare with.</param> public ExcludesBitmask(PropertyDefinitionBase propertyDefinition, int bitmask) : base(propertyDefinition) { this.bitmask = bitmask; }
/// <summary> /// Initializes a new instance of the <see cref="IsLessThan"/> class. /// </summary> /// <param name="propertyDefinition">The definition of the property that is being compared. Property definitions are available as static members from schema classes (for example, EmailMessageSchema.Subject, AppointmentSchema.Start, ContactSchema.GivenName, etc.)</param> /// <param name="otherPropertyDefinition">The definition of the property to compare with. Property definitions are available on schema classes (EmailMessageSchema, AppointmentSchema, etc.)</param> public IsLessThan(PropertyDefinitionBase propertyDefinition, PropertyDefinitionBase otherPropertyDefinition) : base(propertyDefinition, otherPropertyDefinition) { }
/// <summary> /// Removes the specified property definition from the collection. /// </summary> /// <param name="propertyDefinition">The property definition.</param> /// <returns>True if the property definition is successfully removed; otherwise, false</returns> public bool Remove(PropertyDefinitionBase propertyDefinition) { int count = this.propDefSortOrderPairList.RemoveAll((pair) => pair.Key.Equals(propertyDefinition)); return(count > 0); }
/// <summary> /// Determines whether the collection contains the specified property definition. /// </summary> /// <param name="propertyDefinition">The property definition.</param> /// <returns>True if the collection contains the specified property definition; otherwise, false.</returns> internal bool Contains(PropertyDefinitionBase propertyDefinition) { return(this.propDefSortOrderPairList.Exists((pair) => pair.Key.Equals(propertyDefinition))); }
/// <summary> /// Initializes a new instance of the <see cref="IsEqualTo"/> class. /// </summary> /// <param name="propertyDefinition">The definition of the property that is being compared. Property definitions are available as static members from schema classes (for example, EmailMessageSchema.Subject, AppointmentSchema.Start, ContactSchema.GivenName, etc.)</param> /// <param name="value">The value to compare the property with.</param> public IsEqualTo(PropertyDefinitionBase propertyDefinition, object value) : base(propertyDefinition, value) { }
/// <summary> /// Initializes a new instance of the <see cref="RelationalFilter"/> class. /// </summary> /// <param name="propertyDefinition">The definition of the property that is being compared. Property definitions are available as static members from schema classes (for example, EmailMessageSchema.Subject, AppointmentSchema.Start, ContactSchema.GivenName, etc.)</param> /// <param name="value">The value to compare with.</param> internal RelationalFilter(PropertyDefinitionBase propertyDefinition, object value) : base(propertyDefinition) { this.value = value; }
/// <summary> /// Initializes a new instance of the <see cref="Exists"/> class. /// </summary> /// <param name="propertyDefinition">The definition of the property to check the existence of. Property definitions are available as static members from schema classes (for example, EmailMessageSchema.Subject, AppointmentSchema.Start, ContactSchema.GivenName, etc.)</param> public Exists(PropertyDefinitionBase propertyDefinition) : base(propertyDefinition) { }
/// <summary> /// Initializes a new instance of the <see cref="IsGreaterThanOrEqualTo"/> class. /// </summary> /// <param name="propertyDefinition">The definition of the property that is being compared. Property definitions are available as static members from schema classes (for example, EmailMessageSchema.Subject, AppointmentSchema.Start, ContactSchema.GivenName, etc.)</param> /// <param name="value">The value to compare the property with.</param> public IsGreaterThanOrEqualTo(PropertyDefinitionBase propertyDefinition, object value) : base(propertyDefinition, value) { }
/// <summary> /// Tries to read element from XML. /// </summary> /// <param name="reader">The reader.</param> /// <returns>True if element was read.</returns> internal override bool TryReadElementFromXml(EwsServiceXmlReader reader) { return(PropertyDefinitionBase.TryLoadFromXml(reader, ref this.propertyDefinition)); }