コード例 #1
0
        /// <summary>
        /// Deserialize a request to a JsonDocument
        /// </summary>
        public static JsonDocumentMetadata DeserializeJsonDocumentMetadata(string key,
                                                                           HttpResponseHeaders headers,
                                                                           HttpStatusCode statusCode)
        {
            RavenJObject meta = null;

            try
            {
                meta = headers.FilterHeadersToObject();
            }
            catch (JsonReaderException jre)
            {
                throw new JsonReaderException("Invalid Json Response", jre);
            }
            var    etag             = headers.ETag.Tag;
            string lastModified     = headers.GetFirstValue(Constants.RavenLastModified) ?? headers.GetFirstValue(Constants.LastModified);
            var    dateTime         = DateTime.ParseExact(lastModified, new[] { "o", "r" }, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
            var    lastModifiedDate = DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);

            return(new JsonDocumentMetadata
            {
                NonAuthoritativeInformation = statusCode == HttpStatusCode.NonAuthoritativeInformation,
                Key = key,
                Etag = HttpExtensions.EtagHeaderToEtag(etag),
                LastModified = lastModifiedDate,
                Metadata = meta
            });
        }
コード例 #2
0
        /// <summary>
        /// Deserialize a request to a JsonDocument
        /// </summary>
        public static JsonDocument DeserializeJsonDocument(string key, RavenJToken requestJson,
                                                           HttpResponseHeaders headers,
                                                           HttpStatusCode statusCode)
        {
            var jsonData = (RavenJObject)requestJson;
            var meta     = headers.FilterHeadersToObject();

            var etag = headers.ETag.Tag;

            return(new JsonDocument
            {
                DataAsJson = jsonData,
                NonAuthoritativeInformation = statusCode == HttpStatusCode.NonAuthoritativeInformation,
                Key = key,
                Etag = HttpExtensions.EtagHeaderToEtag(etag),
                LastModified = GetLastModifiedDate(headers),
                Metadata = meta
            });
        }
コード例 #3
0
        /// <summary>
        /// Deserialize a request to a JsonDocument
        /// </summary>
        public static JsonDocument DeserializeJsonDocument(string key, RavenJToken requestJson,
                                                           HttpResponseHeaders headers,
                                                           HttpStatusCode statusCode)
        {
            var jsonData = (RavenJObject)requestJson;
            var metadata = headers.FilterHeadersToObject();

            var etag         = headers.ETag.Tag;
            var lastModified = GetLastModifiedDate(headers);

            metadata[Constants.Headers.LastModified] = lastModified;

            return(new JsonDocument
            {
                DataAsJson = jsonData,
                Key = key,
                Etag = HttpExtensions.EtagHeaderToEtag(etag),
                LastModified = lastModified,
                Metadata = metadata
            });
        }