/// <summary>
        /// Copies to items to destinationDocument.
        /// </summary>
        /// <param name="destinationDocument">The destination document.</param>
        public void CopyTo(Document destinationDocument)
        {
            if (destinationDocument == null)
            {
                throw new ArgumentNullException("destinationDocument");
            }

            //Todo: Fix any accidental reordering issues.

            foreach (var key in _orderedKeys)
            {
                if (destinationDocument.ContainsKey(key))
                {
                    destinationDocument.Remove(key);
                }
                destinationDocument[key] = this[key];
            }
        }
Beispiel #2
0
        /// <summary>
        ///   Constructs a DBRef from a document that matches the DBref specification.
        /// </summary>
        public DBRef(Document document)
        {
            if (document == null)
            {
                throw new ArgumentNullException("document");
            }
            if (IsDocumentDBRef(document) == false)
            {
                throw new ArgumentException("Document is not a valid DBRef");
            }

            _collectionName = (String)document[RefName];
            _id             = document[IdName];
            _document       = document;
            if (document.ContainsKey("metadata"))
            {
                MetaData = (Document)document["metadata"];
            }
        }
Beispiel #3
0
 /// <summary>
 /// Determines whether [is document DB ref] [the specified document].
 /// </summary>
 /// <param name="document">The document.</param>
 /// <returns>
 ///     <c>true</c> if [is document DB ref] [the specified document]; otherwise, <c>false</c>.
 /// </returns>
 public static bool IsDocumentDBRef(Document document)
 {
     return(document != null && document.ContainsKey(RefName) && document.ContainsKey(IdName));
 }