本文整理汇总了C#中MongoDB.Bson.IO.BsonBinaryReaderContext类的典型用法代码示例。如果您正苦于以下问题:C# BsonBinaryReaderContext类的具体用法?C# BsonBinaryReaderContext怎么用?C# BsonBinaryReaderContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BsonBinaryReaderContext类属于MongoDB.Bson.IO命名空间,在下文中一共展示了BsonBinaryReaderContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BsonBinaryReaderContext
// constructors
internal BsonBinaryReaderContext(BsonBinaryReaderContext parentContext, ContextType contextType, int startPosition, int size)
{
this.parentContext = parentContext;
this.contextType = contextType;
this.startPosition = startPosition;
this.size = size;
}
示例2: BsonBinaryReaderBookmark
// constructors
internal BsonBinaryReaderBookmark(
BsonReaderState state,
BsonType currentBsonType,
string currentName,
BsonBinaryReaderContext context,
int position)
: base(state, currentBsonType, currentName)
{
_context = context.Clone();
_position = position;
}
示例3: BsonBinaryReaderContext
// constructors
internal BsonBinaryReaderContext(
BsonBinaryReaderContext parentContext,
ContextType contextType,
int startPosition,
int size)
{
_parentContext = parentContext;
_contextType = contextType;
_startPosition = startPosition;
_size = size;
}
示例4: BsonBinaryReaderBookmark
internal BsonBinaryReaderBookmark(
BsonBinaryReaderContext context,
BsonReadState state,
BsonType currentBsonType,
int position
)
{
this.context = context;
this.state = state;
this.currentBsonType = currentBsonType;
this.position = position;
}
示例5: BsonBinaryReader
/// <summary>
/// Initializes a new instance of the BsonBinaryReader class.
/// <param name="buffer">A BsonBuffer.</param>
/// <param name="settings">A BsonBinaryReaderSettings.</param>
/// </summary>
public BsonBinaryReader(
BsonBuffer buffer,
BsonBinaryReaderSettings settings
) {
if (buffer == null) {
this.buffer = new BsonBuffer();
this.disposeBuffer = true; // only call Dispose if we allocated the buffer
} else {
this.buffer = buffer;
this.disposeBuffer = false;
}
this.settings = settings.Freeze();
context = new BsonBinaryReaderContext(null, ContextType.TopLevel, 0, 0);
}
示例6: BsonBinaryReader
// constructors
/// <summary>
/// Initializes a new instance of the BsonBinaryReader class.
/// </summary>
/// <param name="buffer">A BsonBuffer.</param>
/// <param name="settings">A BsonBinaryReaderSettings.</param>
public BsonBinaryReader(BsonBuffer buffer, BsonBinaryReaderSettings settings)
: base(settings)
{
if (buffer == null)
{
_buffer = new BsonBuffer();
_disposeBuffer = true; // only call Dispose if we allocated the buffer
}
else
{
_buffer = buffer;
_disposeBuffer = false;
}
_binaryReaderSettings = settings; // already frozen by base class
_context = new BsonBinaryReaderContext(null, ContextType.TopLevel, 0, 0);
}
示例7: BsonBinaryReader
/// <summary>
/// Initializes a new instance of the BsonBinaryReader class.
/// </summary>
/// <param name="stream">A stream (BsonBinary does not own the stream and will not Dispose it).</param>
/// <param name="settings">A BsonBinaryReaderSettings.</param>
public BsonBinaryReader(Stream stream, BsonBinaryReaderSettings settings)
: base(settings)
{
if (stream == null)
{
throw new ArgumentNullException("stream");
}
if (!stream.CanSeek)
{
throw new ArgumentException("The stream must be capable of seeking.", "stream");
}
_streamReader = new BsonStreamReader(stream, settings.Encoding);
_settings = settings; // already frozen by base class
_context = new BsonBinaryReaderContext(null, ContextType.TopLevel, 0, 0);
}
示例8: GenerateDottedElementName
private string GenerateDottedElementName(BsonBinaryReaderContext context, string elementName)
{
if (context.ContextType == ContextType.Document)
{
return GenerateDottedElementName(context.ParentContext, (context.CurrentElementName ?? "?") + "." + elementName);
}
else if (context.ContextType == ContextType.Array)
{
var indexElementName = context.CurrentArrayIndex.ToString(NumberFormatInfo.InvariantInfo);
return GenerateDottedElementName(context.ParentContext, indexElementName + "." + elementName);
}
else if (context.ParentContext != null)
{
return GenerateDottedElementName(context.ParentContext, "?." + elementName);
}
else
{
return elementName;
}
}
示例9: ReadStartArray
public override void ReadStartArray() {
if (disposed) { ThrowObjectDisposedException(); }
if (state != BsonReadState.Value || currentBsonType != BsonType.Array) {
string message = string.Format("ReadStartArray cannot be called when ReadState is: {0} and BsonType is: {1}", state, currentBsonType);
throw new InvalidOperationException(message);
}
var startPosition = buffer.Position; // position of size field
var size = ReadSize();
context = new BsonBinaryReaderContext(context, ContextType.Array, startPosition, size);
state = BsonReadState.Type;
}
示例10: ReadStartDocument
public override void ReadStartDocument() {
if (disposed) { ThrowObjectDisposedException(); }
if (
state != BsonReadState.Initial &&
state != BsonReadState.Done &&
state != BsonReadState.ScopeDocument &&
(state != BsonReadState.Value || currentBsonType != BsonType.Document)
) {
string message = string.Format("ReadStartDocument cannot be called when ReadState is: {0} and BsonType is: {1}", state, currentBsonType);
throw new InvalidOperationException(message);
}
var contextType = (state == BsonReadState.ScopeDocument) ? ContextType.ScopeDocument : ContextType.Document;
var startPosition = buffer.Position; // position of size field
var size = ReadSize();
context = new BsonBinaryReaderContext(context, contextType, startPosition, size);
state = BsonReadState.Type;
}
示例11: ReadJavaScriptWithScope
/// <summary>
/// Reads a BSON JavaScript with scope from the reader (call ReadStartDocument next to read the scope).
/// </summary>
/// <returns>A string.</returns>
public override string ReadJavaScriptWithScope()
{
if (Disposed) { ThrowObjectDisposedException(); }
VerifyBsonType("ReadJavaScriptWithScope", BsonType.JavaScriptWithScope);
var startPosition = _bsonStream.Position; // position of size field
var size = ReadSize();
_context = new BsonBinaryReaderContext(_context, ContextType.JavaScriptWithScope, startPosition, size);
var code = _bsonStream.ReadString(_settings.Encoding);
State = BsonReaderState.ScopeDocument;
return code;
}
示例12: ReadStartDocument
/// <summary>
/// Reads the start of a BSON document.
/// </summary>
public override void ReadStartDocument() {
if (disposed) { ThrowObjectDisposedException(); }
VerifyBsonType("ReadStartDocument", BsonType.Document);
var contextType = (state == BsonReaderState.ScopeDocument) ? ContextType.ScopeDocument : ContextType.Document;
var startPosition = buffer.Position; // position of size field
var size = ReadSize();
context = new BsonBinaryReaderContext(context, contextType, startPosition, size);
state = BsonReaderState.Type;
}
示例13: ReadJavaScriptWithScope
/// <summary>
/// Reads a BSON JavaScript with scope from the reader (call ReadStartDocument next to read the scope).
/// </summary>
/// <returns>A string.</returns>
public override string ReadJavaScriptWithScope() {
if (disposed) { ThrowObjectDisposedException(); }
VerifyBsonType("ReadJavaScriptWithScope", BsonType.JavaScriptWithScope);
var startPosition = buffer.Position; // position of size field
var size = ReadSize();
context = new BsonBinaryReaderContext(context, ContextType.JavaScriptWithScope, startPosition, size);
var code = buffer.ReadString();
state = BsonReaderState.ScopeDocument;
return code;
}
示例14: BsonBinaryReader
public BsonBinaryReader(
BsonBuffer buffer,
BsonBinaryReaderSettings settings
) {
this.buffer = buffer ?? new BsonBuffer();
this.disposeBuffer = buffer == null; // only call Dispose if we allocated the buffer
this.settings = settings;
context = null;
}
示例15: BsonBinaryReader
public BsonBinaryReader(
BsonBuffer buffer,
BsonBinaryReaderSettings settings
) {
this.buffer = buffer ?? new BsonBuffer();
this.disposeBuffer = buffer == null; // only call Dispose if we allocated the buffer
this.settings = settings;
context = null;
state = BsonReadState.Initial;
currentBsonType = BsonType.Document;
}