MongoDB.Bson.RawBsonDocument.GetValue C# (CSharp) Method

GetValue() public method

Gets the value of an element.
public GetValue ( int index ) : BsonValue
index int The zero based index of the element.
return BsonValue
        public override BsonValue GetValue(int index)
        {
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index");
            }
            ThrowIfDisposed();

            using (var bsonReader = new BsonBinaryReader(new BsonBuffer(CloneSlice(), true), true, _readerSettings))
            {
                bsonReader.ReadStartDocument();
                var i = 0;
                while (bsonReader.ReadBsonType() != BsonType.EndOfDocument)
                {
                    bsonReader.SkipName();
                    if (i == index)
                    {
                        return DeserializeBsonValue(bsonReader);
                    }

                    bsonReader.SkipValue();
                    i++;
                }
                bsonReader.ReadEndDocument();

                throw new ArgumentOutOfRangeException("index");
            }
        }

Same methods

RawBsonDocument::GetValue ( string name ) : BsonValue
RawBsonDocument::GetValue ( string name, BsonValue defaultValue ) : BsonValue