当前位置: 首页>>代码示例>>C#>>正文


C# IO.JsonReaderContext类代码示例

本文整理汇总了C#中MongoDB.Bson.IO.JsonReaderContext的典型用法代码示例。如果您正苦于以下问题:C# JsonReaderContext类的具体用法?C# JsonReaderContext怎么用?C# JsonReaderContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JsonReaderContext类属于MongoDB.Bson.IO命名空间,在下文中一共展示了JsonReaderContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: JsonReader

 // constructors
 /// <summary>
 /// Initializes a new instance of the JsonReader class.
 /// </summary>
 /// <param name="buffer">The buffer.</param>
 /// <param name="settings">The reader settings.</param>
 public JsonReader(JsonBuffer buffer, JsonReaderSettings settings)
     : base(settings)
 {
     _buffer = buffer;
     _jsonReaderSettings = settings; // already frozen by base class
     _context = new JsonReaderContext(null, ContextType.TopLevel);
 }
开发者ID:dngorecki,项目名称:mongo-csharp-driver,代码行数:13,代码来源:JsonReader.cs

示例2: JsonReader

 public JsonReader(
     JsonBuffer buffer
 )
 {
     this.buffer = buffer;
     this.context = new JsonReaderContext(null, ContextType.TopLevel);
 }
开发者ID:modesto,项目名称:mongo-csharp-driver,代码行数:7,代码来源:JsonReader.cs

示例3: JsonReaderContext

 internal JsonReaderContext(
     JsonReaderContext parentContext,
     ContextType contextType
 ) {
     this.parentContext = parentContext;
     this.contextType = contextType;
 }
开发者ID:redforks,项目名称:mongo-csharp-driver,代码行数:7,代码来源:JsonReaderContext.cs

示例4: Clone

 public JsonReaderContext Clone()
 {
     var clone = new JsonReaderContext();
     clone.parentContext = this.parentContext;
     clone.contextType = this.contextType;
     return clone;
 }
开发者ID:Teun,项目名称:mongo-csharp-driver,代码行数:7,代码来源:JsonReaderContext.cs

示例5: JsonReader

 /// <summary>
 /// Initializes a new instance of the JsonReader class.
 /// </summary>
 /// <param name="buffer">The buffer.</param>
 /// <param name="settings">The reader settings.</param>
 public JsonReader(
     JsonBuffer buffer,
     JsonReaderSettings settings
 ) {
     this.buffer = buffer;
     this.settings = settings.Freeze();
     this.context = new JsonReaderContext(null, ContextType.TopLevel);
 }
开发者ID:emiaj,项目名称:mongo-csharp-driver,代码行数:13,代码来源:JsonReader.cs

示例6: JsonReaderBookmark

 // constructors
 internal JsonReaderBookmark(BsonReaderState state, BsonType currentBsonType, string currentName, JsonReaderContext context, JsonToken currentToken, BsonValue currentValue, JsonToken pushedToken, int position)
     : base(state, currentBsonType, currentName)
 {
     _context = context.Clone();
     _currentToken = currentToken;
     _currentValue = currentValue;
     _pushedToken = pushedToken;
     _position = position;
 }
开发者ID:moonreplace,项目名称:mongo-csharp-driver,代码行数:10,代码来源:JsonReaderBookmark.cs

示例7: ReadStartDocument

        /// <summary>
        /// Reads the start of a BSON document.
        /// </summary>
        public override void ReadStartDocument() {
            if (disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadStartDocument", BsonType.Document);

            context = new JsonReaderContext(context, ContextType.Document);
            state = BsonReaderState.Type;
        }
开发者ID:afinnell,项目名称:mongo-csharp-driver,代码行数:10,代码来源:JsonReader.cs

示例8: 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);
     context = new JsonReaderContext(context, ContextType.JavaScriptWithScope);
     state = BsonReaderState.ScopeDocument;
     return currentValue.AsString;
 }
开发者ID:afinnell,项目名称:mongo-csharp-driver,代码行数:11,代码来源:JsonReader.cs

示例9: ReadStartArray

        /// <summary>
        /// Reads the start of a BSON array.
        /// </summary>
        public override void ReadStartArray()
        {
            if (_disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadStartArray", BsonType.Array);

            _context = new JsonReaderContext(_context, ContextType.Array);
            _state = BsonReaderState.Type;
        }
开发者ID:dngorecki,项目名称:mongo-csharp-driver,代码行数:11,代码来源:JsonReader.cs

示例10: JsonReaderContext

 internal JsonReaderContext(JsonReaderContext parentContext, ContextType contextType)
 {
     _parentContext = parentContext;
     _contextType = contextType;
 }
开发者ID:moonreplace,项目名称:mongo-csharp-driver,代码行数:5,代码来源:JsonReaderContext.cs

示例11: ReturnToBookmark

 /// <summary>
 /// Returns the reader to previously bookmarked position and state.
 /// </summary>
 /// <param name="bookmark">The bookmark.</param>
 public override void ReturnToBookmark(
     BsonReaderBookmark bookmark
 ) {
     if (disposed) { ThrowObjectDisposedException(); }
     var jsonReaderBookmark = (JsonReaderBookmark) bookmark;
     state = jsonReaderBookmark.State;
     currentBsonType = jsonReaderBookmark.CurrentBsonType;
     currentName = jsonReaderBookmark.CurrentName;
     context = jsonReaderBookmark.CloneContext();
     currentToken = jsonReaderBookmark.CurrentToken;
     currentValue = jsonReaderBookmark.CurrentValue;
     pushedToken = jsonReaderBookmark.PushedToken;
     buffer.Position = jsonReaderBookmark.Position;
 }
开发者ID:afinnell,项目名称:mongo-csharp-driver,代码行数:18,代码来源:JsonReader.cs

示例12: ReadEndDocument

        /// <summary>
        /// Reads the end of a BSON document from the reader.
        /// </summary>
        public override void ReadEndDocument() {
            if (disposed) { ThrowObjectDisposedException(); }
            if (
                context.ContextType != ContextType.Document &&
                context.ContextType != ContextType.ScopeDocument
            ) {
                ThrowInvalidContextType("ReadEndDocument", context.ContextType, ContextType.Document, ContextType.ScopeDocument);
            }
            if (state == BsonReaderState.Type) {
                ReadBsonType(); // will set state to EndOfDocument if at end of document
            }
            if (state != BsonReaderState.EndOfDocument) {
                ThrowInvalidState("ReadEndDocument", BsonReaderState.EndOfDocument);
            }

            context = context.PopContext();
            if (context != null && context.ContextType == ContextType.JavaScriptWithScope) {
                context = context.PopContext(); // JavaScriptWithScope
                VerifyToken("}"); // outermost closing bracket for JavaScriptWithScope
            }
            switch (context.ContextType) {
                case ContextType.Array: state = BsonReaderState.Type; break;
                case ContextType.Document: state = BsonReaderState.Type; break;
                case ContextType.TopLevel: state = BsonReaderState.Done; break;
                default: throw new BsonInternalException("Unexpected ContextType");
            }

            if (context.ContextType == ContextType.Array || context.ContextType == ContextType.Document) {
                var commaToken = PopToken();
                if (commaToken.Type != JsonTokenType.Comma) {
                    PushToken(commaToken);
                }
            }
        }
开发者ID:afinnell,项目名称:mongo-csharp-driver,代码行数:37,代码来源:JsonReader.cs

示例13: ReadEndArray

        /// <summary>
        /// Reads the end of a BSON array from the reader.
        /// </summary>
        public override void ReadEndArray() {
            if (disposed) { ThrowObjectDisposedException(); }
            if (context.ContextType != ContextType.Array) {
                ThrowInvalidContextType("ReadEndArray", context.ContextType, ContextType.Array);
            }
            if (state == BsonReaderState.Type) {
                ReadBsonType(); // will set state to EndOfArray if at end of array
            }
            if (state != BsonReaderState.EndOfArray) {
                ThrowInvalidState("ReadEndArray", BsonReaderState.EndOfArray);
            }

            context = context.PopContext();
            switch (context.ContextType) {
                case ContextType.Array: state = BsonReaderState.Type; break;
                case ContextType.Document: state = BsonReaderState.Type; break;
                case ContextType.TopLevel: state = BsonReaderState.Done; break;
                default: throw new BsonInternalException("Unexpected ContextType.");
            }

            if (context.ContextType == ContextType.Array || context.ContextType == ContextType.Document) {
                var commaToken = PopToken();
                if (commaToken.Type != JsonTokenType.Comma) {
                    PushToken(commaToken);
                }
            }
        }
开发者ID:afinnell,项目名称:mongo-csharp-driver,代码行数:30,代码来源:JsonReader.cs

示例14: ReturnToBookmark

 public override void ReturnToBookmark(
     BsonReaderBookmark bookmark
 )
 {
     var jsonReaderBookmark = (JsonReaderBookmark) bookmark;
     state = jsonReaderBookmark.State;
     currentBsonType = jsonReaderBookmark.CurrentBsonType;
     currentName = jsonReaderBookmark.CurrentName;
     context = jsonReaderBookmark.Context;
     currentToken = jsonReaderBookmark.CurrentToken;
     currentValue = jsonReaderBookmark.CurrentValue;
     pushedToken = jsonReaderBookmark.PushedToken;
     buffer.Position = jsonReaderBookmark.Position;
 }
开发者ID:modesto,项目名称:mongo-csharp-driver,代码行数:14,代码来源:JsonReader.cs

示例15: ReadEndArray

        public override void ReadEndArray()
        {
            if (disposed) { ThrowObjectDisposedException(); }
            if (context.ContextType != ContextType.Array) {
                var message = string.Format("ReadEndArray cannot be called when ContextType is: {0}", context.ContextType);
                throw new InvalidOperationException(message);
            }
            if (state == BsonReaderState.Type) {
                ReadBsonType(); // will set state to EndOfArray if at end of array
            }
            if (state != BsonReaderState.EndOfArray) {
                var message = string.Format("ReadEndArray cannot be called when State is: {0}", state);
                throw new InvalidOperationException(message);
            }

            context = context.PopContext();
            switch (context.ContextType) {
                case ContextType.Array: state = BsonReaderState.Type; break;
                case ContextType.Document: state = BsonReaderState.Type; break;
                case ContextType.TopLevel: state = BsonReaderState.Done; break;
                default: throw new BsonInternalException("Unexpected ContextType");
            }

            if (context.ContextType == ContextType.Array || context.ContextType == ContextType.Document) {
                var commaToken = PopToken();
                if (commaToken.Type != JsonTokenType.Comma) {
                    PushToken(commaToken);
                }
            }
        }
开发者ID:modesto,项目名称:mongo-csharp-driver,代码行数:30,代码来源:JsonReader.cs


注:本文中的MongoDB.Bson.IO.JsonReaderContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。