public override int IndexOf(BsonValue value, int index, int count)
{
ThrowIfDisposed();
using (var bsonReader = new BsonBinaryReader(new BsonBuffer(CloneSlice(), false), true, _readerSettings))
{
bsonReader.ReadStartDocument();
var i = 0;
while (bsonReader.ReadBsonType() != BsonType.EndOfDocument)
{
bsonReader.SkipName();
if (i >= index)
{
if (count == 0)
{
return -1;
}
if (DeserializeBsonValue(bsonReader).Equals(value))
{
return i;
}
count--;
}
else
{
bsonReader.SkipValue();
}
i++;
}
bsonReader.ReadEndDocument();
return -1;
}
}