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 _additionalProperties) {
    if (propDefBase is PropertyDefinition) {
      PropertyDefinition propertyDefinition = propDefBase;
      if (propertyDefinition.Version!.index >
          request.Service.RequestedServerVersion.index) {
        throw ServiceVersionException("""string.Format(
                              Strings.PropertyIncompatibleWithRequestVersion,
                              propertyDefinition.Name,
                              propertyDefinition.Version)""");
      }

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

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

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

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

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

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

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