/// <summary> /// Checks that the previous segment can be composed upon. /// </summary> /// <param name="previous">previous segment info.</param> private static void CheckSegmentIsComposable(SegmentInfo previous) { if (!IsSegmentComposable(previous)) { // Enumerable and DirectValue results cannot be composed at all, and we don't allow we can't access properties in a single queryable complex either throw DataServiceException.ResourceNotFoundError( Strings.RequestUriProcessor_IEnumerableServiceOperationsCannotBeFurtherComposed(previous.Identifier)); } }
/// <summary> /// Throws if the given segment must be a leaf, as a later segment is being created. /// </summary> /// <param name="previous">The previous segment which may need to be a leaf.</param> private static void ThrowIfMustBeLeafSegment(SegmentInfo previous) { if (previous.IsServiceActionSegment) { throw DataServiceException.CreateBadRequestError(Strings.RequestUriProcessor_MustBeLeafSegment(previous.Identifier)); } if (previous.TargetKind == RequestTargetKind.Batch || previous.TargetKind == RequestTargetKind.Metadata || previous.TargetKind == RequestTargetKind.PrimitiveValue || previous.TargetKind == RequestTargetKind.VoidOperation || previous.TargetKind == RequestTargetKind.OpenPropertyValue || previous.TargetKind == RequestTargetKind.MediaResource || previous.TargetKind == RequestTargetKind.Collection) { // Nothing can come after a $metadata, $value or $batch segment. // Nothing can come after a service operation with void return type. // Nothing can come after a collection property. throw DataServiceException.ResourceNotFoundError(Strings.RequestUriProcessor_MustBeLeafSegment(previous.Identifier)); } }