Exemplo n.º 1
0
 /// <summary>
 /// Copies over all the values of the internal-only properties from one segment to another.
 /// </summary>
 /// <param name="other">Ther segment to copy from.</param>
 internal void CopyValuesFrom(ODataPathSegment other)
 {
     Debug.Assert(other != null, "other != null");
     this.Identifier   = other.Identifier;
     this.SingleResult = other.SingleResult;
     this.TargetEdmNavigationSource = other.TargetEdmNavigationSource;
     this.TargetKind    = other.TargetKind;
     this.TargetEdmType = other.TargetEdmType;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Copies over all the values of the internal-only properties from one segment to another.
 /// </summary>
 /// <param name="other">Ther segment to copy from.</param>
 internal void CopyValuesFrom(ODataPathSegment other)
 {
     DebugUtils.CheckNoExternalCallers();
     Debug.Assert(other != null, "other != null");
     this.Identifier         = other.Identifier;
     this.SingleResult       = other.SingleResult;
     this.TargetEdmEntitySet = other.TargetEdmEntitySet;
     this.TargetKind         = other.TargetKind;
     this.TargetEdmType      = other.TargetEdmType;
 }
Exemplo n.º 3
0
        internal static bool IsAtomResponseFormat(string acceptTypesText, RequestTargetKind targetKind, DataServiceProtocolVersion maxProtocolVersion, Version requestMaxVersion)
        {
            Version effectiveMaxResponseVersion = GetEffectiveMaxResponseVersion(maxProtocolVersion, requestMaxVersion);
            string  mime = SelectResponseMediaType(acceptTypesText, targetKind == RequestTargetKind.Resource, effectiveMaxResponseVersion < RequestDescription.Version3Dot0);

            if (mime == null)
            {
                return(false);
            }
            return(GetContentFormat(mime) == ContentFormat.Atom);
        }
Exemplo n.º 4
0
 internal RequestDescription(RequestTargetKind targetKind, RequestTargetSource targetSource, Uri resultUri)
 {
     SegmentInfo info = new SegmentInfo {
         TargetKind = targetKind,
         TargetSource = targetSource,
         SingleResult = true
     };
     this.segmentInfos = new SegmentInfo[] { info };
     this.resultUri = resultUri;
     this.responseVersion = DataServiceDefaultResponseVersion;
     this.actualResponseVersion = this.ResponseVersion;
     this.PreferenceApplied = System.Data.Services.PreferenceApplied.None;
 }
Exemplo n.º 5
0
        internal RequestDescription(RequestTargetKind targetKind, RequestTargetSource targetSource, Uri resultUri)
        {
            SegmentInfo info = new SegmentInfo {
                TargetKind   = targetKind,
                TargetSource = targetSource,
                SingleResult = true
            };

            this.segmentInfos          = new SegmentInfo[] { info };
            this.resultUri             = resultUri;
            this.responseVersion       = DataServiceDefaultResponseVersion;
            this.actualResponseVersion = this.ResponseVersion;
            this.PreferenceApplied     = System.Data.Services.PreferenceApplied.None;
        }
Exemplo n.º 6
0
        private static void RunSimpleFormatTest(RequestTargetKind requestTargetKind, ODataFormat expectedFormat)
        {
            var requestDescription = new RequestDescription(requestTargetKind, RequestTargetSource.None, new Uri("http://temp.org/"));

            requestDescription.DetermineResponseFormat(new DataServiceSimulator());
            if (expectedFormat == null)
            {
                requestDescription.ResponseFormat.Should().BeNull();
            }
            else
            {
                requestDescription.ResponseFormat.Should().NotBeNull();
                requestDescription.ResponseFormat.Format.Should().BeSameAs(expectedFormat);
            }
        }
Exemplo n.º 7
0
        private static void RunPayloadKindTest(RequestTargetKind requestTargetKind, RequestTargetSource requestTargetSource, ResourceType targetResourceType, bool singleResult, bool isLinkUri, ODataPayloadKind expectedKind)
        {
            var segment = new SegmentInfo
            {
                TargetKind         = requestTargetKind,
                TargetSource       = requestTargetSource,
                TargetResourceType = targetResourceType,
                SingleResult       = singleResult,
                Identifier         = "Fake",
            };

            var operation = new ServiceOperation("Fake", ServiceOperationResultKind.Void, null, null, "GET", null);

            operation.SetReadOnly();
            segment.Operation         = new OperationWrapper(operation);
            segment.ProjectedProperty = new ResourceProperty("Fake", ResourcePropertyKind.Primitive, ResourceType.GetPrimitiveResourceType(typeof(int)));

            SegmentInfo[] segmentInfos;
            if (isLinkUri)
            {
                segmentInfos = new[]
                {
                    new SegmentInfo(),
                    new SegmentInfo
                    {
                        TargetKind = RequestTargetKind.Link,
                    },
                    segment
                };
            }
            else
            {
                segmentInfos = new[]
                {
                    new SegmentInfo
                    {
                        Identifier = "Fake",
                    },
                    new SegmentInfo(),
                    segment
                };
            }

            var requestDescription = new RequestDescription(segmentInfos, new Uri("http://temp.org/"));

            requestDescription.ResponsePayloadKind.Should().Be(expectedKind);
        }
Exemplo n.º 8
0
        /// <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);
        }
Exemplo n.º 9
0
        /// <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
            {
                TargetKind = targetKind,
                TargetSource = targetSource,
                SingleResult = true
            };
            this.segmentInfos = new[] { segment };
            this.resultUri = resultUri;

#if DEBUG
            this.maxFeatureVersion = VersionUtil.Version4Dot0;
#endif
            this.ResponseVersion = VersionUtil.DataServiceDefaultResponseVersion;
            this.ActualResponseVersion = this.ResponseVersion;

            this.Preference = ClientPreference.None;
        }
Exemplo n.º 10
0
        private static void RunPayloadKindTest(RequestTargetKind requestTargetKind, RequestTargetSource requestTargetSource, ResourceType targetResourceType, bool singleResult, bool isLinkUri, ODataPayloadKind expectedKind)
        {
            var segment = new SegmentInfo
            {
                TargetKind = requestTargetKind,
                TargetSource = requestTargetSource,
                TargetResourceType = targetResourceType,
                SingleResult = singleResult,
                Identifier = "Fake",
            };

            var operation = new ServiceOperation("Fake", ServiceOperationResultKind.Void, null, null, "GET", null);
            operation.SetReadOnly();
            segment.Operation = new OperationWrapper(operation);
            segment.ProjectedProperty = new ResourceProperty("Fake", ResourcePropertyKind.Primitive, ResourceType.GetPrimitiveResourceType(typeof(int)));

            SegmentInfo[] segmentInfos;
            if (isLinkUri)
            {
                segmentInfos = new[]
                {
                    new SegmentInfo(),
                    new SegmentInfo
                    {
                       TargetKind = RequestTargetKind.Link,  
                    },
                    segment
                };
            }
            else
            {
                segmentInfos = new[]
                {
                    new SegmentInfo
                    {
                        Identifier = "Fake",
                    },
                    new SegmentInfo(),
                    segment
                };
            }

            var requestDescription = new RequestDescription(segmentInfos, new Uri("http://temp.org/"));
            requestDescription.ResponsePayloadKind.Should().Be(expectedKind);
        }
Exemplo n.º 11
0
 private static void RunSimpleFormatTest(RequestTargetKind requestTargetKind, ODataFormat expectedFormat)
 {
     var requestDescription = new RequestDescription(requestTargetKind, RequestTargetSource.None, new Uri("http://temp.org/"));
     requestDescription.DetermineResponseFormat(new DataServiceSimulator());
     if (expectedFormat == null)
     {
         requestDescription.ResponseFormat.Should().BeNull();
     }
     else
     {
         requestDescription.ResponseFormat.Should().NotBeNull();
         requestDescription.ResponseFormat.Format.Should().BeSameAs(expectedFormat);
     }
 }
Exemplo n.º 12
0
        /// <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);
        }