Exemplo n.º 1
0
        /// <summary>
        /// Translate the json document to a <see cref = "RavenJObject" />
        /// </summary>
        public RavenJObject ToJson(bool checkForId = false)
        {
            DataAsJson.EnsureCannotBeChangeAndEnableSnapshotting();
            Metadata.EnsureCannotBeChangeAndEnableSnapshotting();

            var doc      = (RavenJObject)DataAsJson.CreateSnapshot();
            var metadata = (RavenJObject)Metadata.CreateSnapshot();

            if (LastModified != null)
            {
                metadata[Constants.LastModified]      = LastModified.Value;
                metadata[Constants.RavenLastModified] = LastModified.Value.GetDefaultRavenFormat();
            }
            if (Etag != null)
            {
                metadata["@etag"] = Etag.ToString();
            }
            if (NonAuthoritativeInformation != null)
            {
                metadata["Non-Authoritative-Information"] = NonAuthoritativeInformation.Value;
            }
            if (checkForId && metadata.ContainsKey("@id") == false)
            {
                metadata["@id"] = Key;
            }
            doc["@metadata"] = metadata;

            return(doc);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Translate the json document to a <see cref = "RavenJObject" />
        /// </summary>
        /// <returns></returns>
        public RavenJObject ToJson()
        {
            DataAsJson.EnsureCannotBeChangeAndEnableSnapshotting();
            Metadata.EnsureCannotBeChangeAndEnableSnapshotting();

            var doc      = (RavenJObject)DataAsJson.CreateSnapshot();
            var metadata = (RavenJObject)Metadata.CreateSnapshot();

            if (LastModified != null)
            {
                metadata[Constants.LastModified]      = LastModified.Value;
                metadata[Constants.RavenLastModified] = LastModified.Value.ToString(Default.DateTimeFormatsToWrite, CultureInfo.InvariantCulture);
            }
            if (Etag != null)
            {
                metadata["@etag"] = Etag.ToString();
            }
            if (NonAuthoritativeInformation != null)
            {
                metadata["Non-Authoritative-Information"] = NonAuthoritativeInformation.Value;
            }
            //if (metadata.ContainsKey("@id") == false)
            //	metadata["@id"] = Key;
            doc["@metadata"] = metadata;

            return(doc);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Translate the json document to a <see cref = "RavenJObject" />
        /// </summary>
        /// <returns></returns>
        public RavenJObject ToJson()
        {
            DataAsJson.EnsureSnapshot();
            Metadata.EnsureSnapshot();

            var doc      = (RavenJObject)DataAsJson.CreateSnapshot();
            var metadata = (RavenJObject)Metadata.CreateSnapshot();

            if (LastModified != null)
            {
                metadata[Constants.LastModified] = LastModified.Value;
            }
            if (Etag != null)
            {
                metadata["@etag"] = Etag.Value.ToString();
            }
            if (NonAuthoritativeInformation != null)
            {
                metadata["Non-Authoritative-Information"] = NonAuthoritativeInformation.Value;
            }
            //if (metadata.ContainsKey("@id") == false)
            //	metadata["@id"] = Key;
            doc["@metadata"] = metadata;

            return(doc);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Translate the json document to a <see cref = "RavenJObject" />
        /// </summary>
        /// <returns></returns>
        public RavenJObject ToJson()
        {
            var doc      = (RavenJObject)DataAsJson.CloneToken();
            var metadata = (RavenJObject)Metadata.CloneToken();

            if (LastModified != null)
            {
                metadata[Constants.LastModified] = LastModified.Value;
            }
            if (Etag != null)
            {
                metadata["@etag"] = Etag.Value.ToString();
            }
            if (NonAuthoritativeInformation != null)
            {
                metadata["Non-Authoritative-Information"] = NonAuthoritativeInformation.Value;
            }

            doc["@metadata"] = metadata;

            return(doc);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Translate the json document to a <see cref = "JObject" />
        /// </summary>
        /// <returns></returns>
        public JObject ToJson()
        {
            var docSnapshot      = (JObject)DataAsJson.CloneToken();
            var metadataSnapshot = (JObject)Metadata.CloneToken();

            if (LastModified != null)
            {
                metadataSnapshot[Constants.LastModified] = LastModified.Value;
            }
            if (Etag != null)
            {
                metadataSnapshot["@etag"] = Etag.Value.ToString();
            }
            if (NonAuthoritativeInformation != null)
            {
                metadataSnapshot["Non-Authoritative-Information"] = NonAuthoritativeInformation.Value;
            }
            //if (metadata.ContainsKey("@id") == false)
            //	metadata["@id"] = Key;
            docSnapshot["@metadata"] = metadataSnapshot;

            return(docSnapshot);
        }