本文整理汇总了C#中MongoDB.Bson.IO.BsonBinaryReader.SkipName方法的典型用法代码示例。如果您正苦于以下问题:C# BsonBinaryReader.SkipName方法的具体用法?C# BsonBinaryReader.SkipName怎么用?C# BsonBinaryReader.SkipName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoDB.Bson.IO.BsonBinaryReader
的用法示例。
在下文中一共展示了BsonBinaryReader.SkipName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEnumerator
/// <summary>
/// Gets an enumerator that can enumerate the elements of the array.
/// </summary>
/// <returns>An enumerator.</returns>
public override IEnumerator<BsonValue> GetEnumerator()
{
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)
{
bsonReader.SkipName();
yield return DeserializeBsonValue(context);
}
bsonReader.ReadEndDocument();
}
}
示例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: Contains
/// <summary>
/// Tests whether the array contains a value.
/// </summary>
/// <param name="value">The value to test for.</param>
/// <returns>True if the array contains the value.</returns>
public override bool Contains(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)
{
bsonReader.SkipName();
if (DeserializeBsonValue(context).Equals(value))
{
return true;
}
}
bsonReader.ReadEndDocument();
return false;
}
}
示例4: CopyTo
public override void CopyTo(object[] array, int arrayIndex)
{
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)
{
bsonReader.SkipName();
array[arrayIndex++] = DeserializeBsonValue(context).RawValue;
}
bsonReader.ReadEndDocument();
}
}
示例5: 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");
}
}
示例6: 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.");
}
}
示例7: GetEnumerator
/// <summary>
/// Gets an enumerator that can enumerate the elements of the array.
/// </summary>
/// <returns>An enumerator.</returns>
public override IEnumerator<BsonValue> GetEnumerator()
{
ThrowIfDisposed();
using (var bsonReader = new BsonBinaryReader(new BsonBuffer(CloneSlice(), false), true, _readerSettings))
{
bsonReader.ReadStartDocument();
while (bsonReader.ReadBsonType() != BsonType.EndOfDocument)
{
bsonReader.SkipName();
yield return DeserializeBsonValue(bsonReader);
}
bsonReader.ReadEndDocument();
}
}
示例8: 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;
}
}
示例9: Contains
/// <summary>
/// Tests whether the array contains a value.
/// </summary>
/// <param name="value">The value to test for.</param>
/// <returns>True if the array contains the value.</returns>
public override bool Contains(BsonValue value)
{
ThrowIfDisposed();
using (var bsonReader = new BsonBinaryReader(new BsonBuffer(CloneSlice(), false), true, _readerSettings))
{
bsonReader.ReadStartDocument();
while (bsonReader.ReadBsonType() != BsonType.EndOfDocument)
{
bsonReader.SkipName();
if (DeserializeBsonValue(bsonReader).Equals(value))
{
return true;
}
}
bsonReader.ReadEndDocument();
return false;
}
}
示例10: CopyTo
public override void CopyTo(object[] array, int arrayIndex)
{
ThrowIfDisposed();
using (var bsonReader = new BsonBinaryReader(new BsonBuffer(CloneSlice(), false), true, _readerSettings))
{
bsonReader.ReadStartDocument();
while (bsonReader.ReadBsonType() != BsonType.EndOfDocument)
{
bsonReader.SkipName();
array[arrayIndex++] = DeserializeBsonValue(bsonReader).RawValue;
}
bsonReader.ReadEndDocument();
}
}
示例11: 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.");
}
}
示例12: 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");
}
}
示例13: MaterializeThisLevel
private IEnumerable<BsonValue> MaterializeThisLevel()
{
var values = new List<BsonValue>();
var readerSettings = _readerSettings.Clone();
readerSettings.MaxDocumentSize = _slice.Length;
using (var bsonReader = new BsonBinaryReader(new BsonBuffer(CloneSlice(), true), true, readerSettings))
{
bsonReader.ReadStartDocument();
BsonType bsonType;
while ((bsonType = bsonReader.ReadBsonType()) != BsonType.EndOfDocument)
{
bsonReader.SkipName();
BsonValue value;
switch (bsonType)
{
case BsonType.Array: value = DeserializeLazyBsonArray(bsonReader); break;
case BsonType.Document: value = DeserializeLazyBsonDocument(bsonReader); break;
default: value = (BsonValue)BsonValueSerializer.Instance.Deserialize(bsonReader, typeof(BsonValue), null); break;
}
values.Add(value);
}
bsonReader.ReadEndDocument();
}
return values;
}
示例14: MaterializeThisLevel
private IEnumerable<BsonValue> MaterializeThisLevel()
{
var values = new List<BsonValue>();
using (var stream = new ByteBufferStream(_slice, ownsBuffer: false))
using (var bsonReader = new BsonBinaryReader(stream, _readerSettings))
{
var context = BsonDeserializationContext.CreateRoot(bsonReader);
bsonReader.ReadStartDocument();
BsonType bsonType;
while ((bsonType = bsonReader.ReadBsonType()) != BsonType.EndOfDocument)
{
bsonReader.SkipName();
BsonValue value;
switch (bsonType)
{
case BsonType.Array: value = DeserializeLazyBsonArray(bsonReader); break;
case BsonType.Document: value = DeserializeLazyBsonDocument(bsonReader); break;
default: value = BsonValueSerializer.Instance.Deserialize(context); break;
}
values.Add(value);
}
bsonReader.ReadEndDocument();
}
return values;
}
示例15: DeserializeThisLevel
private void DeserializeThisLevel()
{
var values = new List<BsonValue>();
using (var bsonReader = new BsonBinaryReader(new BsonBuffer(CloneSlice(), true), true, _readerSettings))
{
bsonReader.ReadStartDocument();
BsonType bsonType;
while ((bsonType = bsonReader.ReadBsonType()) != BsonType.EndOfDocument)
{
bsonReader.SkipName();
BsonValue value;
switch (bsonType)
{
case BsonType.Array: value = DeserializeLazyBsonArray(bsonReader); break;
case BsonType.Document: value = DeserializeLazyBsonDocument(bsonReader); break;
default: value = (BsonValue)BsonValueSerializer.Instance.Deserialize(bsonReader, typeof(BsonValue), null); break;
}
values.Add(value);
}
bsonReader.ReadEndDocument();
}
var slice = _slice;
try
{
_slice = null;
Clear();
AddRange(values);
slice.Dispose();
}
catch
{
try { Clear(); } catch { }
_slice = slice;
throw;
}
}