/// <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> /// 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> /// Tries to load from XML. /// </summary> /// <param name="jsonObject">The json object.</param> /// <returns>True if property was loaded.</returns> internal static PropertyDefinitionBase TryLoadFromJson(JsonObject jsonObject) { switch (jsonObject.ReadTypeString()) { case JsonNames.PathToUnindexedFieldType: return(ServiceObjectSchema.FindPropertyDefinition(jsonObject.ReadAsString(XmlAttributeNames.FieldURI))); case JsonNames.PathToIndexedFieldType: return(new IndexedPropertyDefinition( jsonObject.ReadAsString(XmlAttributeNames.FieldURI), jsonObject.ReadAsString(XmlAttributeNames.FieldIndex))); case JsonNames.PathToExtendedFieldType: ExtendedPropertyDefinition propertyDefinition = new ExtendedPropertyDefinition(); propertyDefinition.LoadFromJson(jsonObject); return(propertyDefinition); default: return(null); } }
/// <summary> /// Parses the message XML. /// </summary> /// <param name="reader">The reader.</param> private void ParseMessageXml(EwsServiceXmlReader reader) { do { reader.Read(); if (reader.IsStartElement()) { switch (reader.LocalName) { case XmlElementNames.Value: this.errorDetails.Add(reader.ReadAttributeValue(XmlAttributeNames.Name), reader.ReadElementValue()); break; case XmlElementNames.FieldURI: this.errorProperties.Add(ServiceObjectSchema.FindPropertyDefinition(reader.ReadAttributeValue(XmlAttributeNames.FieldURI))); break; case XmlElementNames.IndexedFieldURI: this.errorProperties.Add( new IndexedPropertyDefinition( reader.ReadAttributeValue(XmlAttributeNames.FieldURI), reader.ReadAttributeValue(XmlAttributeNames.FieldIndex))); break; case XmlElementNames.ExtendedFieldURI: ExtendedPropertyDefinition extendedPropDef = new ExtendedPropertyDefinition(); extendedPropDef.LoadFromXml(reader); this.errorProperties.Add(extendedPropDef); break; default: break; } } } while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.MessageXml)); }