ValidateForRequest method

void ValidateForRequest(
  1. ServiceRequestBase request,
  2. bool summaryPropertiesOnly
)
Validates this property set instance for request to ensure that: 1. Properties are valid for the request server version. 2. If only summary properties are legal for this request (e.g. FindItem) then only summary properties were specified. The request. if set to then only summary properties are allowed.

Implementation

void ValidateForRequest(
    ServiceRequestBase request, bool summaryPropertiesOnly) {
  for (PropertyDefinitionBase propDefBase in this._additionalProperties) {
    if (propDefBase is PropertyDefinition) {
      PropertyDefinition propertyDefinition =
          propDefBase as PropertyDefinition;
      if (propertyDefinition.Version!.index >
          request.Service.RequestedServerVersion.index) {
        throw new ServiceVersionException("""string.Format(
                              Strings.PropertyIncompatibleWithRequestVersion,
                              propertyDefinition.Name,
                              propertyDefinition.Version)""");
      }

      if (summaryPropertiesOnly &&
          !propertyDefinition.HasFlag(PropertyDefinitionFlags.CanFind,
              request.Service.RequestedServerVersion)) {
        throw new ServiceValidationException("""string.Format(
                              Strings.NonSummaryPropertyCannotBeUsed,
                              propertyDefinition.Name,
                              request.GetXmlElementName())""");
      }
    }
  }

  if (this.FilterHtmlContent != null) {
    if (request.Service.RequestedServerVersion.index <
        ExchangeVersion.Exchange2010.index) {
      throw new ServiceVersionException("""string.Format(
                          Strings.PropertyIncompatibleWithRequestVersion,
                          "FilterHtmlContent",
                          ExchangeVersion.Exchange2010)""");
    }
  }

  if (this.ConvertHtmlCodePageToUTF8 != null) {
    if (request.Service.RequestedServerVersion.index <
        ExchangeVersion.Exchange2010_SP1.index) {
      throw new ServiceVersionException("""string.Format(
                          Strings.PropertyIncompatibleWithRequestVersion,
                          "ConvertHtmlCodePageToUTF8",
                          ExchangeVersion.Exchange2010_SP1)""");
    }
  }

  if (!StringUtils.IsNullOrEmpty(this.InlineImageUrlTemplate)) {
    if (request.Service.RequestedServerVersion.index <
        ExchangeVersion.Exchange2013.index) {
      throw new ServiceVersionException("""string.Format(
                          Strings.PropertyIncompatibleWithRequestVersion,
                          "InlineImageUrlTemplate",
                          ExchangeVersion.Exchange2013.index)""");
    }
  }

  if (this.BlockExternalImages != null) {
    if (request.Service.RequestedServerVersion.index <
        ExchangeVersion.Exchange2013.index) {
      throw new ServiceVersionException("""string.Format(
                          Strings.PropertyIncompatibleWithRequestVersion,
                          "BlockExternalImages",
                          ExchangeVersion.Exchange2013.index)""");
    }
  }

  if (this.AddBlankTargetToLinks != null) {
    if (request.Service.RequestedServerVersion.index <
        ExchangeVersion.Exchange2013.index) {
      throw new ServiceVersionException("""string.Format(
                          Strings.PropertyIncompatibleWithRequestVersion,
                          "AddTargetToLinks",
                          ExchangeVersion.Exchange2013.index)""");
    }
  }

  if (this.MaximumBodySize != null) {
    if (request.Service.RequestedServerVersion.index <
        ExchangeVersion.Exchange2013.index) {
      throw new ServiceVersionException("""string.Format(
                          Strings.PropertyIncompatibleWithRequestVersion,
                          "MaximumBodySize",
                          ExchangeVersion.Exchange2013.index)""");
    }
  }
}