本文整理汇总了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");
}
}