/// <summary> /// Initializes a new RequestDescription for a query specified by the /// request Uri. /// </summary> /// <param name="targetKind">The kind of target for the request.</param> /// <param name="targetSource">The source for this target.</param> /// <param name="resultUri">URI to the results requested (with no query component).</param> internal RequestDescription(RequestTargetKind targetKind, RequestTargetSource targetSource, Uri resultUri) { WebUtil.DebugEnumIsDefined(targetKind); Debug.Assert(resultUri != null, "resultUri != null"); Debug.Assert(resultUri.IsAbsoluteUri, "resultUri.IsAbsoluteUri(" + resultUri + ")"); SegmentInfo segment = new SegmentInfo(); segment.TargetKind = targetKind; segment.TargetSource = targetSource; segment.SingleResult = true; this.segmentInfos = new SegmentInfo[] { segment }; this.resultUri = resultUri; this.requireMinimumVersion = new Version(1, 0); this.responseVersion = DataServiceDefaultResponseVersion; this.maxFeatureVersion = new Version(1, 0); }
/// <summary>In DEBUG builds, ensures that invariants for the class hold.</summary> internal void AssertValid() { WebUtil.DebugEnumIsDefined(this.TargetKind); WebUtil.DebugEnumIsDefined(this.TargetSource); Debug.Assert(this.TargetKind != RequestTargetKind.Nothing, "targetKind != RequestTargetKind.Nothing"); Debug.Assert( this.TargetContainer == null || this.TargetSource != RequestTargetSource.None, "'None' targets should not have a resource set."); Debug.Assert( this.TargetKind != RequestTargetKind.Resource || this.TargetContainer != null || this.TargetKind == RequestTargetKind.OpenProperty || this.TargetSource == RequestTargetSource.ServiceOperation, "All resource targets (except for some service operations and open properties) should have a container."); Debug.Assert( this.TargetContainer == null || this.TargetContainer.ResourceType.IsAssignableFrom(this.TargetResourceType), "If targetContainer is assigned, it should be equal to (or assignable to) the segment's element type."); Debug.Assert( !String.IsNullOrEmpty(this.Identifier) || RequestTargetSource.None == this.TargetSource || RequestTargetKind.VoidServiceOperation == this.TargetKind, "identifier must not be empty or null except for none or void service operation"); }