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

ContainsValue() public method

Tests whether the document contains an element with the specified value.
public ContainsValue ( BsonValue value ) : bool
value BsonValue The value of the element to look for.
return bool
        public override bool ContainsValue(BsonValue value)
        {
            ThrowIfDisposed();
            using (var bsonReader = new BsonBinaryReader(new BsonBuffer(CloneSlice(), true), true, _readerSettings))
            {
                bsonReader.ReadStartDocument();
                while (bsonReader.ReadBsonType() != BsonType.EndOfDocument)
                {
                    bsonReader.SkipName();
                    if (DeserializeBsonValue(bsonReader).Equals(value))
                    {
                        return true;
                    }
                }
                bsonReader.ReadEndDocument();

                return false;
            }
        }