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


C# BsonReaderState类代码示例

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


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

示例1: BsonReader

 /// <summary>
 /// Initializes a new instance of the BsonReader class.
 /// </summary>
 /// <param name="settings">The reader settings.</param>
 protected BsonReader(
     BsonReaderSettings settings
 )
 {
     this.settings = settings.FrozenCopy();
     this.state = BsonReaderState.Initial;
 }
开发者ID:vshlos,项目名称:mongo-csharp-driver,代码行数:11,代码来源:BsonReader.cs

示例2: 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

示例3: BsonReader

        // constructors
        /// <summary>
        /// Initializes a new instance of the BsonReader class.
        /// </summary>
        /// <param name="settings">The reader settings.</param>
        protected BsonReader(BsonReaderSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            _settings = settings.FrozenCopy();
            _state = BsonReaderState.Initial;
        }
开发者ID:joeenzminger,项目名称:mongo-csharp-driver,代码行数:15,代码来源:BsonReader.cs

示例4: BsonReaderBookmark

 protected BsonReaderBookmark(
     BsonReaderState state,
     BsonType currentBsonType,
     string currentName
 )
 {
     this.state = state;
     this.currentBsonType = currentBsonType;
     this.currentName = currentName;
 }
开发者ID:jenrom,项目名称:mongo-csharp-driver,代码行数:10,代码来源:BsonReaderBookmark.cs

示例5: BsonDocumentReaderBookmark

 // constructors
 internal BsonDocumentReaderBookmark(
     BsonReaderState state,
     BsonType currentBsonType,
     string currentName,
     BsonDocumentReaderContext context,
     BsonValue currentValue)
     : base(state, currentBsonType, currentName)
 {
     _context = context.Clone();
     _currentValue = currentValue;
 }
开发者ID:horizon3d,项目名称:SequoiaDB,代码行数:12,代码来源:BsonDocumentReaderBookmark.cs

示例6: BsonBinaryReaderBookmark

 // constructors
 internal BsonBinaryReaderBookmark(
     BsonReaderState state,
     BsonType currentBsonType,
     string currentName,
     BsonBinaryReaderContext context,
     int position)
     : base(state, currentBsonType, currentName)
 {
     _context = context.Clone();
     _position = position;
 }
开发者ID:CloudMetal,项目名称:mongo-csharp-driver,代码行数:12,代码来源:BsonBinaryReaderBookmark.cs

示例7: ReadType

        private void ReadType(BsonType type)
        {
            switch (type)
            {
                case BsonType.Number:
                    double d = ReadDouble();

                    if (_floatParseHandling == FloatParseHandling.Decimal)
                        SetToken(JsonToken.Float, Convert.ToDecimal(d, CultureInfo.InvariantCulture));
                    else
                        SetToken(JsonToken.Float, d);
                    break;
                case BsonType.String:
                case BsonType.Symbol:
                    SetToken(JsonToken.String, ReadLengthString());
                    break;
                case BsonType.Object:
                {
                    SetToken(JsonToken.StartObject);

                    ContainerContext newContext = new ContainerContext(BsonType.Object);
                    PushContext(newContext);
                    newContext.Length = ReadInt32();
                    break;
                }
                case BsonType.Array:
                {
                    SetToken(JsonToken.StartArray);

                    ContainerContext newContext = new ContainerContext(BsonType.Array);
                    PushContext(newContext);
                    newContext.Length = ReadInt32();
                    break;
                }
                case BsonType.Binary:
                    SetToken(JsonToken.Bytes, ReadBinary());
                    break;
                case BsonType.Undefined:
                    SetToken(JsonToken.Undefined);
                    break;
                case BsonType.Oid:
                    byte[] oid = ReadBytes(12);
                    SetToken(JsonToken.Bytes, oid);
                    break;
                case BsonType.Boolean:
                    bool b = Convert.ToBoolean(ReadByte());
                    SetToken(JsonToken.Boolean, b);
                    break;
                case BsonType.Date:
                    long ticks = ReadInt64();
                    DateTime utcDateTime = DateTimeUtils.ConvertJavaScriptTicksToDateTime(ticks);

                    DateTime dateTime;
                    switch (DateTimeKindHandling)
                    {
                        case DateTimeKind.Unspecified:
                            dateTime = DateTime.SpecifyKind(utcDateTime, DateTimeKind.Unspecified);
                            break;
                        case DateTimeKind.Local:
                            dateTime = utcDateTime.ToLocalTime();
                            break;
                        default:
                            dateTime = utcDateTime;
                            break;
                    }

                    SetToken(JsonToken.Date, dateTime);
                    break;
                case BsonType.Null:
                    SetToken(JsonToken.Null);
                    break;
                case BsonType.Regex:
                    string expression = ReadString();
                    string modifiers = ReadString();

                    string regex = @"/" + expression + @"/" + modifiers;
                    SetToken(JsonToken.String, regex);
                    break;
                case BsonType.Reference:
                    SetToken(JsonToken.StartObject);
                    _bsonReaderState = BsonReaderState.ReferenceStart;
                    break;
                case BsonType.Code:
                    SetToken(JsonToken.String, ReadLengthString());
                    break;
                case BsonType.CodeWScope:
                    SetToken(JsonToken.StartObject);
                    _bsonReaderState = BsonReaderState.CodeWScopeStart;
                    break;
                case BsonType.Integer:
                    SetToken(JsonToken.Integer, (long)ReadInt32());
                    break;
                case BsonType.TimeStamp:
                case BsonType.Long:
                    SetToken(JsonToken.Integer, ReadInt64());
                    break;
                default:
                    throw new ArgumentOutOfRangeException("type", "Unexpected BsonType value: " + type);
            }
        }
开发者ID:925coder,项目名称:Newtonsoft.Json,代码行数:100,代码来源:BsonReader.cs

示例8: ReadReference

 private bool ReadReference()
 {
     switch (CurrentState)
     {
         case State.ObjectStart:
         {
             SetToken(JsonToken.PropertyName, JsonTypeReflector.RefPropertyName);
             _bsonReaderState = BsonReaderState.ReferenceRef;
             return true;
         }
         case State.Property:
         {
             if (_bsonReaderState == BsonReaderState.ReferenceRef)
             {
                 SetToken(JsonToken.String, ReadLengthString());
                 return true;
             }
             else if (_bsonReaderState == BsonReaderState.ReferenceId)
             {
                 SetToken(JsonToken.Bytes, ReadBytes(12));
                 return true;
             }
             else
             {
                 throw JsonReaderException.Create(this, "Unexpected state when reading BSON reference: " + _bsonReaderState);
             }
         }
         case State.PostValue:
         {
             if (_bsonReaderState == BsonReaderState.ReferenceRef)
             {
                 SetToken(JsonToken.PropertyName, JsonTypeReflector.IdPropertyName);
                 _bsonReaderState = BsonReaderState.ReferenceId;
                 return true;
             }
             else if (_bsonReaderState == BsonReaderState.ReferenceId)
             {
                 SetToken(JsonToken.EndObject);
                 _bsonReaderState = BsonReaderState.Normal;
                 return true;
             }
             else
             {
                 throw JsonReaderException.Create(this, "Unexpected state when reading BSON reference: " + _bsonReaderState);
             }
         }
         default:
             throw JsonReaderException.Create(this, "Unexpected state when reading BSON reference: " + CurrentState);
     }
 }
开发者ID:925coder,项目名称:Newtonsoft.Json,代码行数:50,代码来源:BsonReader.cs

示例9: ReadCodeWScope

        private bool ReadCodeWScope()
        {
            switch (_bsonReaderState)
            {
                case BsonReaderState.CodeWScopeStart:
                    SetToken(JsonToken.PropertyName, "$code");
                    _bsonReaderState = BsonReaderState.CodeWScopeCode;
                    return true;
                case BsonReaderState.CodeWScopeCode:
                    // total CodeWScope size - not used
                    ReadInt32();

                    SetToken(JsonToken.String, ReadLengthString());
                    _bsonReaderState = BsonReaderState.CodeWScopeScope;
                    return true;
                case BsonReaderState.CodeWScopeScope:
                    if (CurrentState == State.PostValue)
                    {
                        SetToken(JsonToken.PropertyName, "$scope");
                        return true;
                    }
                    else
                    {
                        SetToken(JsonToken.StartObject);
                        _bsonReaderState = BsonReaderState.CodeWScopeScopeObject;

                        ContainerContext newContext = new ContainerContext(BsonType.Object);
                        PushContext(newContext);
                        newContext.Length = ReadInt32();

                        return true;
                    }
                case BsonReaderState.CodeWScopeScopeObject:
                    bool result = ReadNormal();
                    if (result && TokenType == JsonToken.EndObject)
                        _bsonReaderState = BsonReaderState.CodeWScopeScopeEnd;

                    return result;
                case BsonReaderState.CodeWScopeScopeEnd:
                    SetToken(JsonToken.EndObject);
                    _bsonReaderState = BsonReaderState.Normal;
                    return true;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
开发者ID:925coder,项目名称:Newtonsoft.Json,代码行数:46,代码来源:BsonReader.cs

示例10: VerifyBsonType

 /// <summary>
 /// Verifies the current state and BsonType of the reader.
 /// </summary>
 /// <param name="methodName">The name of the method calling this one.</param>
 /// <param name="requiredBsonType">The required BSON type.</param>
 protected void VerifyBsonType(string methodName, BsonType requiredBsonType)
 {
     if (state == BsonReaderState.Initial || state == BsonReaderState.ScopeDocument || state == BsonReaderState.Type)
     {
         ReadBsonType();
     }
     if (state == BsonReaderState.Name)
     {
         // ignore name
         state = BsonReaderState.Value;
     }
     if (state != BsonReaderState.Value)
     {
         ThrowInvalidState(methodName, BsonReaderState.Value);
     }
     if (currentBsonType != requiredBsonType)
     {
         var message = string.Format(
             "{0} can only be called when CurrentBsonType is {1}, not when CurrentBsonType is {2}.",
             methodName, requiredBsonType, currentBsonType);
         throw new InvalidOperationException(message);
     }
 }
开发者ID:kamaradclimber,项目名称:mongo-csharp-driver,代码行数:28,代码来源:BsonReader.cs

示例11: ReadName

        /// <summary>
        /// Reads the name of an element from the reader.
        /// </summary>
        /// <returns>The name of the element.</returns>
        public string ReadName()
        {
            if (disposed) { ThrowObjectDisposedException(); }
            if (state == BsonReaderState.Type)
            {
                ReadBsonType();
            }
            if (state != BsonReaderState.Name)
            {
                ThrowInvalidState("ReadName", BsonReaderState.Name);
            }

            state = BsonReaderState.Value;
            return currentName;
        }
开发者ID:kamaradclimber,项目名称:mongo-csharp-driver,代码行数:19,代码来源:BsonReader.cs

示例12: BsonBaseReader

 /// <summary>
 /// Initializes a new instance of the BsonBaseReader class.
 /// </summary>
 protected BsonBaseReader() {
     state = BsonReaderState.Initial;
 }
开发者ID:emiaj,项目名称:mongo-csharp-driver,代码行数:6,代码来源:BsonBaseReader.cs

示例13: ReadType

    private void ReadType(BsonType type)
    {
      switch (type)
      {
        case BsonType.Number:
          SetToken(JsonToken.Float, ReadDouble());
          break;
        case BsonType.String:
        case BsonType.Symbol:
          SetToken(JsonToken.String, ReadLengthString());
          break;
        case BsonType.Object:
          {
            SetToken(JsonToken.StartObject);

            ContainerContext newContext = new ContainerContext(JTokenType.Object);
            _stack.Add(newContext);
            newContext.Length = ReadInt32();
            break;
          }
        case BsonType.Array:
          {
            SetToken(JsonToken.StartArray);

            ContainerContext newContext = new ContainerContext(JTokenType.Array);
            _stack.Add(newContext);
            newContext.Length = ReadInt32();
            break;
          }
        case BsonType.Binary:
          SetToken(JsonToken.Bytes, ReadBinary());
          break;
        case BsonType.Undefined:
          SetToken(JsonToken.Undefined);
          break;
        case BsonType.Oid:
          byte[] oid = ReadBytes(12);
          SetToken(JsonToken.Bytes, oid);
          break;
        case BsonType.Boolean:
          bool b = Convert.ToBoolean(ReadByte());
          SetToken(JsonToken.Boolean, b);
          break;
        case BsonType.Date:
          long ticks = ReadInt64();
          DateTime dateTime = JsonConvert.ConvertJavaScriptTicksToDateTime(ticks);
          SetToken(JsonToken.Date, dateTime);
          break;
        case BsonType.Null:
          SetToken(JsonToken.Null);
          break;
        case BsonType.Regex:
          string expression = ReadString();
          string modifiers = ReadString();

          string regex = @"/" + expression + @"/" + modifiers;
          SetToken(JsonToken.String, regex);
          break;
        case BsonType.Reference:
          SetToken(JsonToken.StartObject);
          _bsonReaderState = BsonReaderState.ReferenceStart;
          break;
        case BsonType.Code:
          SetToken(JsonToken.String, ReadLengthString());
          break;
        case BsonType.CodeWScope:
          SetToken(JsonToken.StartObject);
          _bsonReaderState = BsonReaderState.CodeWScopeStart;
          break;
        case BsonType.Integer:
          SetToken(JsonToken.Integer, (long)ReadInt32());
          break;
        case BsonType.TimeStamp:
        case BsonType.Long:
          SetToken(JsonToken.Integer, ReadInt64());
          break;
        default:
          throw new ArgumentOutOfRangeException("type", "Unexpected BsonType value: " + type);
      }
    }
开发者ID:anukat2015,项目名称:sones,代码行数:80,代码来源:BsonReader.cs

示例14: ReadName

        /// <summary>
        /// Reads the name of an element from the reader.
        /// </summary>
        /// <returns>The name of the element.</returns>
        public override string ReadName() {
            if (disposed) { ThrowObjectDisposedException(); }
            if (state == BsonReaderState.Type) {
                ReadBsonType();
            }
            if (state != BsonReaderState.Name) {
                var message = string.Format("ReadName cannot be called when State is: {0}", state);
                throw new InvalidOperationException(message);
            }

            state = BsonReaderState.Value;
            return currentName;
        }
开发者ID:oskysal,项目名称:mongo-csharp-driver,代码行数:17,代码来源:BsonBaseReader.cs


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