示例#1
0
        /// <summary>
        /// Converts the BsonDocument to a Hashtable.
        /// </summary>
        /// <returns>A hashtable.</returns>
        public Hashtable ToHashtable()
        {
            var options = new BsonTypeMapperOptions
            {
                DuplicateNameHandling   = DuplicateNameHandling.ThrowException,
                MapBsonArrayTo          = typeof(object[]), // TODO: should this be ArrayList?
                MapBsonDocumentTo       = typeof(Hashtable),
                MapOldBinaryToByteArray = false
            };

            return((Hashtable)BsonTypeMapper.MapToDotNetValue(this, options));
        }
示例#2
0
        /// <summary>
        /// Converts the BsonDocument to a Dictionary&lt;string, object&gt;.
        /// </summary>
        /// <returns>A dictionary.</returns>
        public Dictionary <string, object> ToDictionary()
        {
            var options = new BsonTypeMapperOptions
            {
                DuplicateNameHandling   = DuplicateNameHandling.ThrowException,
                MapBsonArrayTo          = typeof(object[]), // TODO: should this be List<object>?
                MapBsonDocumentTo       = typeof(Dictionary <string, object>),
                MapOldBinaryToByteArray = false
            };

            return((Dictionary <string, object>)BsonTypeMapper.MapToDotNetValue(this, options));
        }