本文整理匯總了C#中MongoDB.Bson.IO.BsonBinaryReader.SkipValue方法的典型用法代碼示例。如果您正苦於以下問題:C# BsonBinaryReader.SkipValue方法的具體用法?C# BsonBinaryReader.SkipValue怎麽用?C# BsonBinaryReader.SkipValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MongoDB.Bson.IO.BsonBinaryReader
的用法示例。
在下文中一共展示了BsonBinaryReader.SkipValue方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ArgumentOutOfRangeException
// public indexers
/// <summary>
/// Gets or sets a value by position.
/// </summary>
/// <param name="index">The position.</param>
/// <returns>The value.</returns>
public override BsonValue this[int index]
{
get
{
if (index < 0)
{
throw new ArgumentOutOfRangeException("index");
}
ThrowIfDisposed();
using (var stream = new ByteBufferStream(_slice, ownsBuffer: false))
using (var bsonReader = new BsonBinaryReader(stream, _readerSettings))
{
bsonReader.ReadStartDocument();
var i = 0;
while (bsonReader.ReadBsonType() != BsonType.EndOfDocument)
{
bsonReader.SkipName();
if (i == index)
{
var context = BsonDeserializationContext.CreateRoot(bsonReader);
return DeserializeBsonValue(context);
}
bsonReader.SkipValue();
i++;
}
bsonReader.ReadEndDocument();
throw new ArgumentOutOfRangeException("index");
}
}
set
{
throw new NotSupportedException("RawBsonArray instances are immutable.");
}
}
示例2: IndexOf
/// <summary>
/// Gets the index of a value in the array.
/// </summary>
/// <param name="value">The value to search for.</param>
/// <param name="index">The zero based index at which to start the search.</param>
/// <param name="count">The number of elements to search.</param>
/// <returns>The zero based index of the value (or -1 if not found).</returns>
public override int IndexOf(BsonValue value, int index, int count)
{
ThrowIfDisposed();
using (var stream = new ByteBufferStream(_slice, ownsBuffer: false))
using (var bsonReader = new BsonBinaryReader(stream, _readerSettings))
{
var context = BsonDeserializationContext.CreateRoot(bsonReader);
bsonReader.ReadStartDocument();
var i = 0;
while (bsonReader.ReadBsonType() != BsonType.EndOfDocument)
{
bsonReader.SkipName();
if (i >= index)
{
if (count == 0)
{
return -1;
}
if (DeserializeBsonValue(context).Equals(value))
{
return i;
}
count--;
}
else
{
bsonReader.SkipValue();
}
i++;
}
bsonReader.ReadEndDocument();
return -1;
}
}
示例3: GetElement
/// <summary>
/// Gets an element of this document.
/// </summary>
/// <param name="index">The zero based index of the element.</param>
/// <returns>
/// The element.
/// </returns>
public override BsonElement GetElement(int index)
{
if (index < 0)
{
throw new ArgumentOutOfRangeException("index");
}
ThrowIfDisposed();
using (var stream = new ByteBufferStream(_slice, ownsBuffer: false))
using (var bsonReader = new BsonBinaryReader(stream, _readerSettings))
{
var context = BsonDeserializationContext.CreateRoot(bsonReader);
bsonReader.ReadStartDocument();
var i = 0;
while (bsonReader.ReadBsonType() != BsonType.EndOfDocument)
{
if (i == index)
{
var name = bsonReader.ReadName();
var value = DeserializeBsonValue(context);
return new BsonElement(name, value);
}
bsonReader.SkipName();
bsonReader.SkipValue();
i++;
}
bsonReader.ReadEndDocument();
throw new ArgumentOutOfRangeException("index");
}
}
示例4: TryGetValue
/// <summary>
/// Tries to get the value of an element of this document.
/// </summary>
/// <param name="name">The name of the element.</param>
/// <param name="value">The value of the element.</param>
/// <returns>
/// True if an element with that name was found.
/// </returns>
public override bool TryGetValue(string name, out BsonValue value)
{
ThrowIfDisposed();
using (var stream = new ByteBufferStream(_slice, ownsBuffer: false))
using (var bsonReader = new BsonBinaryReader(stream, _readerSettings))
{
var context = BsonDeserializationContext.CreateRoot(bsonReader);
bsonReader.ReadStartDocument();
while (bsonReader.ReadBsonType() != BsonType.EndOfDocument)
{
if (bsonReader.ReadName() == name)
{
value = DeserializeBsonValue(context);
return true;
}
bsonReader.SkipValue();
}
bsonReader.ReadEndDocument();
value = null;
return false;
}
}
示例5: Contains
/// <summary>
/// Tests whether the document contains an element with the specified name.
/// </summary>
/// <param name="name">The name of the element to look for.</param>
/// <returns>
/// True if the document contains an element with the specified name.
/// </returns>
public override bool Contains(string name)
{
if (name == null)
{
throw new ArgumentNullException("name");
}
ThrowIfDisposed();
using (var stream = new ByteBufferStream(_slice, ownsBuffer: false))
using (var bsonReader = new BsonBinaryReader(stream, _readerSettings))
{
bsonReader.ReadStartDocument();
while (bsonReader.ReadBsonType() != BsonType.EndOfDocument)
{
if (bsonReader.ReadName() == name)
{
return true;
}
bsonReader.SkipValue();
}
bsonReader.ReadEndDocument();
return false;
}
}
示例6: IndexOf
/// <summary>
/// Gets the index of a value in the array.
/// </summary>
/// <param name="value">The value to search for.</param>
/// <param name="index">The zero based index at which to start the search.</param>
/// <param name="count">The number of elements to search.</param>
/// <returns>The zero based index of the value (or -1 if not found).</returns>
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;
}
}
示例7: ArgumentOutOfRangeException
// public indexers
/// <summary>
/// Gets or sets a value by position.
/// </summary>
/// <param name="index">The position.</param>
/// <returns>The value.</returns>
public override BsonValue this[int index]
{
get
{
if (index < 0)
{
throw new ArgumentOutOfRangeException("index");
}
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)
{
return DeserializeBsonValue(bsonReader);
}
bsonReader.SkipValue();
i++;
}
bsonReader.ReadEndDocument();
throw new ArgumentOutOfRangeException("index");
}
}
set
{
throw new NotSupportedException("RawBsonArray instances are immutable.");
}
}
示例8: TryGetValue
/// <summary>
/// Tries to get the value of an element of this document.
/// </summary>
/// <param name="name">The name of the element.</param>
/// <param name="value">The value of the element.</param>
/// <returns>
/// True if an element with that name was found.
/// </returns>
public override bool TryGetValue(string name, out BsonValue value)
{
ThrowIfDisposed();
using (var bsonReader = new BsonBinaryReader(new BsonBuffer(CloneSlice(), true), true, _readerSettings))
{
bsonReader.ReadStartDocument();
while (bsonReader.ReadBsonType() != BsonType.EndOfDocument)
{
if (bsonReader.ReadName() == name)
{
value = DeserializeBsonValue(bsonReader);
return true;
}
bsonReader.SkipValue();
}
bsonReader.ReadEndDocument();
value = null;
return false;
}
}
示例9: GetValue
/// <summary>
/// Gets the value of an element.
/// </summary>
/// <param name="index">The zero based index of the element.</param>
/// <returns>
/// The value of the element.
/// </returns>
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");
}
}