Ejemplo n.º 1
0
        private bool ReadCodeWScope()
        {
            switch (this._bsonReaderState)
            {
            case BsonReader.BsonReaderState.CodeWScopeStart:
            {
                base.SetToken(JsonToken.PropertyName, "$code");
                this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeCode;
                return(true);
            }

            case BsonReader.BsonReaderState.CodeWScopeCode:
            {
                this.method_0();
                base.SetToken(JsonToken.String, this.ReadLengthString());
                this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeScope;
                return(true);
            }

            case BsonReader.BsonReaderState.CodeWScopeScope:
            {
                if (base.CurrentState == JsonReader.State.PostValue)
                {
                    base.SetToken(JsonToken.PropertyName, "$scope");
                    return(true);
                }
                base.SetToken(JsonToken.StartObject);
                this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeScopeObject;
                BsonReader.ContainerContext containerContext = new BsonReader.ContainerContext(BsonType.Object);
                this.PushContext(containerContext);
                containerContext.Length = this.method_0();
                return(true);
            }

            case BsonReader.BsonReaderState.CodeWScopeScopeObject:
            {
                bool flag = this.ReadNormal();
                if (flag && this.TokenType == JsonToken.EndObject)
                {
                    this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeScopeEnd;
                }
                return(flag);
            }

            case BsonReader.BsonReaderState.CodeWScopeScopeEnd:
            {
                base.SetToken(JsonToken.EndObject);
                this._bsonReaderState = BsonReader.BsonReaderState.Normal;
                return(true);
            }

            default:
            {
                throw new ArgumentOutOfRangeException();
            }
            }
        }
Ejemplo n.º 2
0
 private void PopContext()
 {
     this._stack.RemoveAt(this._stack.Count - 1);
     if (this._stack.Count == 0)
     {
         this._currentContext = null;
         return;
     }
     this._currentContext = this._stack[this._stack.Count - 1];
 }
Ejemplo n.º 3
0
 private void PopContext()
 {
     this._stack.RemoveAt(this._stack.Count - 1);
     if (this._stack.Count != 0)
     {
         this._currentContext = this._stack[this._stack.Count - 1];
     }
     else
     {
         this._currentContext = null;
     }
 }
Ejemplo n.º 4
0
 private void PopContext()
 {
     this._stack.RemoveAt(this._stack.Count - 1);
     if (this._stack.Count == 0)
     {
         this._currentContext = (BsonReader.ContainerContext)null;
     }
     else
     {
         this._currentContext = this._stack[this._stack.Count - 1];
     }
 }
 private void PopContext()
 {
     this._stack.RemoveAt(this._stack.get_Count() - 1);
     if (this._stack.get_Count() == 0)
     {
         this._currentContext = null;
     }
     else
     {
         this._currentContext = this._stack.get_Item(this._stack.get_Count() - 1);
     }
 }
Ejemplo n.º 6
0
        private bool ReadCodeWScope()
        {
            switch (this._bsonReaderState)
            {
            case BsonReader.BsonReaderState.CodeWScopeStart:
                this.SetToken(JsonToken.PropertyName, (object)"$code");
                this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeCode;
                return(true);

            case BsonReader.BsonReaderState.CodeWScopeCode:
                this.ReadInt32();
                this.SetToken(JsonToken.String, (object)this.ReadLengthString());
                this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeScope;
                return(true);

            case BsonReader.BsonReaderState.CodeWScopeScope:
                if (this.CurrentState == JsonReader.State.PostValue)
                {
                    this.SetToken(JsonToken.PropertyName, (object)"$scope");
                    return(true);
                }
                this.SetToken(JsonToken.StartObject);
                this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeScopeObject;
                BsonReader.ContainerContext newContext = new BsonReader.ContainerContext(BsonType.Object);
                this.PushContext(newContext);
                newContext.Length = this.ReadInt32();
                return(true);

            case BsonReader.BsonReaderState.CodeWScopeScopeObject:
                int num = this.ReadNormal() ? 1 : 0;
                if (num == 0)
                {
                    return(num != 0);
                }
                if (this.TokenType != JsonToken.EndObject)
                {
                    return(num != 0);
                }
                this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeScopeEnd;
                return(num != 0);

            case BsonReader.BsonReaderState.CodeWScopeScopeEnd:
                this.SetToken(JsonToken.EndObject);
                this._bsonReaderState = BsonReader.BsonReaderState.Normal;
                return(true);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 7
0
 private bool ReadCodeWScope()
 {
   switch (this._bsonReaderState)
   {
     case BsonReader.BsonReaderState.CodeWScopeStart:
       this.SetToken(JsonToken.PropertyName, (object) "$code");
       this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeCode;
       return true;
     case BsonReader.BsonReaderState.CodeWScopeCode:
       this.ReadInt32();
       this.SetToken(JsonToken.String, (object) this.ReadLengthString());
       this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeScope;
       return true;
     case BsonReader.BsonReaderState.CodeWScopeScope:
       if (this.CurrentState == JsonReader.State.PostValue)
       {
         this.SetToken(JsonToken.PropertyName, (object) "$scope");
         return true;
       }
       else
       {
         this.SetToken(JsonToken.StartObject);
         this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeScopeObject;
         BsonReader.ContainerContext newContext = new BsonReader.ContainerContext(BsonType.Object);
         this.PushContext(newContext);
         newContext.Length = this.ReadInt32();
         return true;
       }
     case BsonReader.BsonReaderState.CodeWScopeScopeObject:
       bool flag = this.ReadNormal();
       if (flag && this.TokenType == JsonToken.EndObject)
         this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeScopeEnd;
       return flag;
     case BsonReader.BsonReaderState.CodeWScopeScopeEnd:
       this.SetToken(JsonToken.EndObject);
       this._bsonReaderState = BsonReader.BsonReaderState.Normal;
       return true;
     default:
       throw new ArgumentOutOfRangeException();
   }
 }
Ejemplo n.º 8
0
        private void ReadType(BsonType type)
        {
            DateTime dateTime;

            switch (type)
            {
            case BsonType.Number:
            {
                this.SetToken(JsonToken.Float, this.ReadDouble());
                break;
            }

            case BsonType.String:
            case BsonType.Symbol:
            {
                this.SetToken(JsonToken.String, this.ReadLengthString());
                break;
            }

            case BsonType.Object:
            {
                base.SetToken(JsonToken.StartObject);
                BsonReader.ContainerContext containerContext = new BsonReader.ContainerContext(BsonType.Object);
                this.PushContext(containerContext);
                containerContext.Length = this.ReadInt32();
                break;
            }

            case BsonType.Array:
            {
                base.SetToken(JsonToken.StartArray);
                BsonReader.ContainerContext containerContext1 = new BsonReader.ContainerContext(BsonType.Array);
                this.PushContext(containerContext1);
                containerContext1.Length = this.ReadInt32();
                break;
            }

            case BsonType.Binary:
            {
                this.SetToken(JsonToken.Bytes, this.ReadBinary());
                break;
            }

            case BsonType.Undefined:
            {
                base.SetToken(JsonToken.Undefined);
                break;
            }

            case BsonType.Oid:
            {
                this.SetToken(JsonToken.Bytes, this.ReadBytes(12));
                break;
            }

            case BsonType.Boolean:
            {
                bool flag = Convert.ToBoolean(this.ReadByte());
                this.SetToken(JsonToken.Boolean, flag);
                break;
            }

            case BsonType.Date:
            {
                DateTime     dateTime1            = JsonConvert.ConvertJavaScriptTicksToDateTime(this.ReadInt64());
                DateTimeKind dateTimeKindHandling = this.DateTimeKindHandling;
                if (dateTimeKindHandling == DateTimeKind.Unspecified)
                {
                    dateTime = DateTime.SpecifyKind(dateTime1, DateTimeKind.Unspecified);
                }
                else
                {
                    dateTime = (dateTimeKindHandling == DateTimeKind.Local ? dateTime1.ToLocalTime() : dateTime1);
                }
                this.SetToken(JsonToken.Date, dateTime);
                break;
            }

            case BsonType.Null:
            {
                base.SetToken(JsonToken.Null);
                break;
            }

            case BsonType.Regex:
            {
                string str  = this.ReadString();
                string str1 = this.ReadString();
                string str2 = string.Concat("/", str, "/", str1);
                this.SetToken(JsonToken.String, str2);
                break;
            }

            case BsonType.Reference:
            {
                base.SetToken(JsonToken.StartObject);
                this._bsonReaderState = BsonReader.BsonReaderState.ReferenceStart;
                break;
            }

            case BsonType.Code:
            {
                this.SetToken(JsonToken.String, this.ReadLengthString());
                break;
            }

            case BsonType.CodeWScope:
            {
                base.SetToken(JsonToken.StartObject);
                this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeStart;
                break;
            }

            case BsonType.Integer:
            {
                this.SetToken(JsonToken.Integer, (long)this.ReadInt32());
                break;
            }

            case BsonType.TimeStamp:
            case BsonType.Long:
            {
                this.SetToken(JsonToken.Integer, this.ReadInt64());
                break;
            }

            default:
            {
                throw new ArgumentOutOfRangeException("type", string.Concat("Unexpected BsonType value: ", type));
            }
            }
        }
Ejemplo n.º 9
0
        private bool ReadNormal()
        {
            BsonType bsonType;

            switch (base.CurrentState)
            {
            case JsonReader.State.Start:
            {
                JsonToken jsonToken = (!this._readRootValueAsArray ? JsonToken.StartObject : JsonToken.StartArray);
                bsonType = (!this._readRootValueAsArray ? BsonType.Object : BsonType.Array);
                base.SetToken(jsonToken);
                BsonReader.ContainerContext containerContext = new BsonReader.ContainerContext(bsonType);
                this.PushContext(containerContext);
                containerContext.Length = this.ReadInt32();
                return(true);
            }

            case JsonReader.State.Complete:
            case JsonReader.State.Closed:
            {
                return(false);
            }

            case JsonReader.State.Property:
            {
                this.ReadType(this._currentElementType);
                return(true);
            }

            case JsonReader.State.ObjectStart:
            case JsonReader.State.ArrayStart:
            case JsonReader.State.PostValue:
            {
                BsonReader.ContainerContext containerContext1 = this._currentContext;
                if (containerContext1 == null)
                {
                    return(false);
                }
                int length = containerContext1.Length - 1;
                if (containerContext1.Position < length)
                {
                    if (containerContext1.Type != BsonType.Array)
                    {
                        base.SetToken(JsonToken.PropertyName, this.ReadElement());
                        return(true);
                    }
                    this.ReadElement();
                    this.ReadType(this._currentElementType);
                    return(true);
                }
                if (containerContext1.Position != length)
                {
                    throw JsonReaderException.Create(this, "Read past end of current container context.");
                }
                if (this.ReadByte() != 0)
                {
                    throw JsonReaderException.Create(this, "Unexpected end of object byte value.");
                }
                this.PopContext();
                if (this._currentContext != null)
                {
                    this.MovePosition(containerContext1.Length);
                }
                base.SetToken((containerContext1.Type == BsonType.Object ? JsonToken.EndObject : JsonToken.EndArray));
                return(true);
            }

            case JsonReader.State.Object:
            case JsonReader.State.Array:
            {
                throw new ArgumentOutOfRangeException();
            }

            case JsonReader.State.ConstructorStart:
            case JsonReader.State.Constructor:
            case JsonReader.State.Error:
            case JsonReader.State.Finished:
            {
                return(false);
            }

            default:
            {
                throw new ArgumentOutOfRangeException();
            }
            }
        }
Ejemplo n.º 10
0
 private void PushContext(BsonReader.ContainerContext newContext)
 {
   this._stack.Add(newContext);
   this._currentContext = newContext;
 }
Ejemplo n.º 11
0
 // Token: 0x060000A7 RID: 167
 // RVA: 0x00029B78 File Offset: 0x00027D78
 private void PopContext()
 {
     this._stack.RemoveAt(this._stack.Count - 1);
     if (this._stack.Count == 0)
     {
         this._currentContext = null;
         return;
     }
     this._currentContext = this._stack[this._stack.Count - 1];
 }
Ejemplo n.º 12
0
        private void ReadType(BsonType type)
        {
            switch (type)
            {
            case BsonType.Number:
                this.SetToken(JsonToken.Float, this.ReadDouble());
                break;

            case BsonType.String:
            case BsonType.Symbol:
                this.SetToken(JsonToken.String, this.ReadLengthString());
                break;

            case BsonType.Object:
            {
                base.SetToken(JsonToken.StartObject);
                BsonReader.ContainerContext containerContext = new BsonReader.ContainerContext(BsonType.Object);
                this.PushContext(containerContext);
                containerContext.Length = this.ReadInt32();
                break;
            }

            case BsonType.Array:
            {
                base.SetToken(JsonToken.StartArray);
                BsonReader.ContainerContext containerContext2 = new BsonReader.ContainerContext(BsonType.Array);
                this.PushContext(containerContext2);
                containerContext2.Length = this.ReadInt32();
                break;
            }

            case BsonType.Binary:
                this.SetToken(JsonToken.Bytes, this.ReadBinary());
                break;

            case BsonType.Undefined:
                base.SetToken(JsonToken.Undefined);
                break;

            case BsonType.Oid:
            {
                byte[] value = this.ReadBytes(12);
                this.SetToken(JsonToken.Bytes, value);
                break;
            }

            case BsonType.Boolean:
            {
                bool flag = Convert.ToBoolean(this.ReadByte());
                this.SetToken(JsonToken.Boolean, flag);
                break;
            }

            case BsonType.Date:
            {
                long         javaScriptTicks      = this.ReadInt64();
                DateTime     dateTime             = JsonConvert.ConvertJavaScriptTicksToDateTime(javaScriptTicks);
                DateTimeKind dateTimeKindHandling = this.DateTimeKindHandling;
                DateTime     dateTime2;
                if (dateTimeKindHandling != DateTimeKind.Unspecified)
                {
                    if (dateTimeKindHandling != DateTimeKind.Local)
                    {
                        dateTime2 = dateTime;
                    }
                    else
                    {
                        dateTime2 = dateTime.ToLocalTime();
                    }
                }
                else
                {
                    dateTime2 = DateTime.SpecifyKind(dateTime, DateTimeKind.Unspecified);
                }
                this.SetToken(JsonToken.Date, dateTime2);
                break;
            }

            case BsonType.Null:
                base.SetToken(JsonToken.Null);
                break;

            case BsonType.Regex:
            {
                string str    = this.ReadString();
                string str2   = this.ReadString();
                string value2 = "/" + str + "/" + str2;
                this.SetToken(JsonToken.String, value2);
                break;
            }

            case BsonType.Reference:
                base.SetToken(JsonToken.StartObject);
                this._bsonReaderState = BsonReader.BsonReaderState.ReferenceStart;
                break;

            case BsonType.Code:
                this.SetToken(JsonToken.String, this.ReadLengthString());
                break;

            case BsonType.CodeWScope:
                base.SetToken(JsonToken.StartObject);
                this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeStart;
                break;

            case BsonType.Integer:
                this.SetToken(JsonToken.Integer, (long)this.ReadInt32());
                break;

            case BsonType.TimeStamp:
            case BsonType.Long:
                this.SetToken(JsonToken.Integer, this.ReadInt64());
                break;

            default:
                throw new ArgumentOutOfRangeException("type", "Unexpected BsonType value: " + type);
            }
        }
Ejemplo n.º 13
0
        private void ReadType(BsonType type)
        {
            switch (type)
            {
            case BsonType.Number:
                this.SetToken(JsonToken.Float, (object)this.ReadDouble());
                break;

            case BsonType.String:
            case BsonType.Symbol:
                this.SetToken(JsonToken.String, (object)this.ReadLengthString());
                break;

            case BsonType.Object:
                this.SetToken(JsonToken.StartObject);
                BsonReader.ContainerContext newContext1 = new BsonReader.ContainerContext(BsonType.Object);
                this.PushContext(newContext1);
                newContext1.Length = this.ReadInt32();
                break;

            case BsonType.Array:
                this.SetToken(JsonToken.StartArray);
                BsonReader.ContainerContext newContext2 = new BsonReader.ContainerContext(BsonType.Array);
                this.PushContext(newContext2);
                newContext2.Length = this.ReadInt32();
                break;

            case BsonType.Binary:
                this.SetToken(JsonToken.Bytes, (object)this.ReadBinary());
                break;

            case BsonType.Undefined:
                this.SetToken(JsonToken.Undefined);
                break;

            case BsonType.Oid:
                this.SetToken(JsonToken.Bytes, (object)this.ReadBytes(12));
                break;

            case BsonType.Boolean:
                this.SetToken(JsonToken.Boolean, (object)(bool)(Convert.ToBoolean(this.ReadByte()) ? 1 : 0));
                break;

            case BsonType.Date:
                DateTime dateTime1 = JsonConvert.ConvertJavaScriptTicksToDateTime(this.ReadInt64());
                DateTime dateTime2;
                switch (this.DateTimeKindHandling)
                {
                case DateTimeKind.Unspecified:
                    dateTime2 = DateTime.SpecifyKind(dateTime1, DateTimeKind.Unspecified);
                    break;

                case DateTimeKind.Local:
                    dateTime2 = dateTime1.ToLocalTime();
                    break;

                default:
                    dateTime2 = dateTime1;
                    break;
                }
                this.SetToken(JsonToken.Date, (object)dateTime2);
                break;

            case BsonType.Null:
                this.SetToken(JsonToken.Null);
                break;

            case BsonType.Regex:
                this.SetToken(JsonToken.String, (object)("/" + this.ReadString() + "/" + this.ReadString()));
                break;

            case BsonType.Reference:
                this.SetToken(JsonToken.StartObject);
                this._bsonReaderState = BsonReader.BsonReaderState.ReferenceStart;
                break;

            case BsonType.Code:
                this.SetToken(JsonToken.String, (object)this.ReadLengthString());
                break;

            case BsonType.CodeWScope:
                this.SetToken(JsonToken.StartObject);
                this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeStart;
                break;

            case BsonType.Integer:
                this.SetToken(JsonToken.Integer, (object)(long)this.ReadInt32());
                break;

            case BsonType.TimeStamp:
            case BsonType.Long:
                this.SetToken(JsonToken.Integer, (object)this.ReadInt64());
                break;

            default:
                throw new ArgumentOutOfRangeException("type", "Unexpected BsonType value: " + (object)type);
            }
        }
Ejemplo n.º 14
0
        private void ReadType(BsonType type)
        {
            switch (type)
            {
            case BsonType.Number:
                double num = this.ReadDouble();
                if (this._floatParseHandling == FloatParseHandling.Decimal)
                {
                    this.SetToken(JsonToken.Float, (object)Convert.ToDecimal((object)num, (IFormatProvider)CultureInfo.InvariantCulture));
                    break;
                }
                this.SetToken(JsonToken.Float, (object)num);
                break;

            case BsonType.String:
            case BsonType.Symbol:
                this.SetToken(JsonToken.String, (object)this.ReadLengthString());
                break;

            case BsonType.Object:
                this.SetToken(JsonToken.StartObject);
                BsonReader.ContainerContext newContext1 = new BsonReader.ContainerContext(BsonType.Object);
                this.PushContext(newContext1);
                newContext1.Length = this.ReadInt32();
                break;

            case BsonType.Array:
                this.SetToken(JsonToken.StartArray);
                BsonReader.ContainerContext newContext2 = new BsonReader.ContainerContext(BsonType.Array);
                this.PushContext(newContext2);
                newContext2.Length = this.ReadInt32();
                break;

            case BsonType.Binary:
                BsonBinaryType binaryType;
                byte[]         b = this.ReadBinary(out binaryType);
                this.SetToken(JsonToken.Bytes, binaryType != BsonBinaryType.Uuid ? (object)b : (object)new Guid(b));
                break;

            case BsonType.Undefined:
                this.SetToken(JsonToken.Undefined);
                break;

            case BsonType.Oid:
                this.SetToken(JsonToken.Bytes, (object)this.ReadBytes(12));
                break;

            case BsonType.Boolean:
                this.SetToken(JsonToken.Boolean, (object)Convert.ToBoolean(this.ReadByte()));
                break;

            case BsonType.Date:
                DateTime dateTime1 = DateTimeUtils.ConvertJavaScriptTicksToDateTime(this.ReadInt64());
                DateTime dateTime2;
                switch (this.DateTimeKindHandling)
                {
                case DateTimeKind.Unspecified:
                    dateTime2 = DateTime.SpecifyKind(dateTime1, DateTimeKind.Unspecified);
                    break;

                case DateTimeKind.Local:
                    dateTime2 = dateTime1.ToLocalTime();
                    break;

                default:
                    dateTime2 = dateTime1;
                    break;
                }
                this.SetToken(JsonToken.Date, (object)dateTime2);
                break;

            case BsonType.Null:
                this.SetToken(JsonToken.Null);
                break;

            case BsonType.Regex:
                this.SetToken(JsonToken.String, (object)("/" + this.ReadString() + "/" + this.ReadString()));
                break;

            case BsonType.Reference:
                this.SetToken(JsonToken.StartObject);
                this._bsonReaderState = BsonReader.BsonReaderState.ReferenceStart;
                break;

            case BsonType.Code:
                this.SetToken(JsonToken.String, (object)this.ReadLengthString());
                break;

            case BsonType.CodeWScope:
                this.SetToken(JsonToken.StartObject);
                this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeStart;
                break;

            case BsonType.Integer:
                this.SetToken(JsonToken.Integer, (object)(long)this.ReadInt32());
                break;

            case BsonType.TimeStamp:
            case BsonType.Long:
                this.SetToken(JsonToken.Integer, (object)this.ReadInt64());
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), "Unexpected BsonType value: " + (object)type);
            }
        }
Ejemplo n.º 15
0
        private bool ReadNormal()
        {
            switch (this.CurrentState)
            {
            case JsonReader.State.Start:
                JsonToken newToken = !this._readRootValueAsArray ? JsonToken.StartObject : JsonToken.StartArray;
                int       num1     = !this._readRootValueAsArray ? 3 : 4;
                this.SetToken(newToken);
                BsonReader.ContainerContext newContext = new BsonReader.ContainerContext((BsonType)num1);
                this.PushContext(newContext);
                newContext.Length = this.ReadInt32();
                return(true);

            case JsonReader.State.Complete:
            case JsonReader.State.Closed:
                return(false);

            case JsonReader.State.Property:
                this.ReadType(this._currentElementType);
                return(true);

            case JsonReader.State.ObjectStart:
            case JsonReader.State.ArrayStart:
            case JsonReader.State.PostValue:
                BsonReader.ContainerContext currentContext = this._currentContext;
                if (currentContext == null)
                {
                    return(false);
                }
                int num2 = currentContext.Length - 1;
                if (currentContext.Position < num2)
                {
                    if (currentContext.Type == BsonType.Array)
                    {
                        this.ReadElement();
                        this.ReadType(this._currentElementType);
                        return(true);
                    }
                    this.SetToken(JsonToken.PropertyName, (object)this.ReadElement());
                    return(true);
                }
                if (currentContext.Position != num2)
                {
                    throw JsonReaderException.Create((JsonReader)this, "Read past end of current container context.");
                }
                if (this.ReadByte() != (byte)0)
                {
                    throw JsonReaderException.Create((JsonReader)this, "Unexpected end of object byte value.");
                }
                this.PopContext();
                if (this._currentContext != null)
                {
                    this.MovePosition(currentContext.Length);
                }
                this.SetToken(currentContext.Type == BsonType.Object ? JsonToken.EndObject : JsonToken.EndArray);
                return(true);

            case JsonReader.State.ConstructorStart:
            case JsonReader.State.Constructor:
            case JsonReader.State.Error:
            case JsonReader.State.Finished:
                return(false);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 16
0
 private bool ReadNormal()
 {
   switch (this.CurrentState)
   {
     case JsonReader.State.Start:
       JsonToken newToken = !this._readRootValueAsArray ? JsonToken.StartObject : JsonToken.StartArray;
       BsonType type = !this._readRootValueAsArray ? BsonType.Object : BsonType.Array;
       this.SetToken(newToken);
       BsonReader.ContainerContext newContext = new BsonReader.ContainerContext(type);
       this.PushContext(newContext);
       newContext.Length = this.ReadInt32();
       return true;
     case JsonReader.State.Complete:
     case JsonReader.State.Closed:
       return false;
     case JsonReader.State.Property:
       this.ReadType(this._currentElementType);
       return true;
     case JsonReader.State.ObjectStart:
     case JsonReader.State.ArrayStart:
     case JsonReader.State.PostValue:
       BsonReader.ContainerContext containerContext = this._currentContext;
       if (containerContext == null)
         return false;
       int num = containerContext.Length - 1;
       if (containerContext.Position < num)
       {
         if (containerContext.Type == BsonType.Array)
         {
           this.ReadElement();
           this.ReadType(this._currentElementType);
           return true;
         }
         else
         {
           this.SetToken(JsonToken.PropertyName, (object) this.ReadElement());
           return true;
         }
       }
       else
       {
         if (containerContext.Position != num)
           throw JsonReaderException.Create((JsonReader) this, "Read past end of current container context.");
         if ((int) this.ReadByte() != 0)
           throw JsonReaderException.Create((JsonReader) this, "Unexpected end of object byte value.");
         this.PopContext();
         if (this._currentContext != null)
           this.MovePosition(containerContext.Length);
         this.SetToken(containerContext.Type == BsonType.Object ? JsonToken.EndObject : JsonToken.EndArray);
         return true;
       }
     case JsonReader.State.ConstructorStart:
     case JsonReader.State.Constructor:
     case JsonReader.State.Error:
     case JsonReader.State.Finished:
       return false;
     default:
       throw new ArgumentOutOfRangeException();
   }
 }
Ejemplo n.º 17
0
 private void PopContext()
 {
   this._stack.RemoveAt(this._stack.Count - 1);
   if (this._stack.Count == 0)
     this._currentContext = (BsonReader.ContainerContext) null;
   else
     this._currentContext = this._stack[this._stack.Count - 1];
 }
Ejemplo n.º 18
0
 // Token: 0x060000A4 RID: 164
 // RVA: 0x00029850 File Offset: 0x00027A50
 private bool ReadCodeWScope()
 {
     switch (this._bsonReaderState)
     {
     case BsonReader.BsonReaderState.CodeWScopeStart:
         base.SetToken(JsonToken.PropertyName, "$code");
         this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeCode;
         return true;
     case BsonReader.BsonReaderState.CodeWScopeCode:
         this.ReadInt32();
         base.SetToken(JsonToken.String, this.ReadLengthString());
         this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeScope;
         return true;
     case BsonReader.BsonReaderState.CodeWScopeScope:
     {
         if (base.CurrentState == JsonReader.State.PostValue)
         {
             base.SetToken(JsonToken.PropertyName, "$scope");
             return true;
         }
         base.SetToken(JsonToken.StartObject);
         this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeScopeObject;
         BsonReader.ContainerContext containerContext = new BsonReader.ContainerContext(BsonType.Object);
         this.PushContext(containerContext);
         containerContext.Length = this.ReadInt32();
         return true;
     }
     case BsonReader.BsonReaderState.CodeWScopeScopeObject:
     {
         bool result;
         if ((result = this.ReadNormal()) && this.TokenType == JsonToken.EndObject)
         {
             this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeScopeEnd;
         }
         return result;
     }
     case BsonReader.BsonReaderState.CodeWScopeScopeEnd:
         base.SetToken(JsonToken.EndObject);
         this._bsonReaderState = BsonReader.BsonReaderState.Normal;
         return true;
     default:
         throw new ArgumentOutOfRangeException();
     }
 }
Ejemplo n.º 19
0
 private void ReadType(BsonType type)
 {
   switch (type)
   {
     case BsonType.Number:
       this.SetToken(JsonToken.Float, (object) this.ReadDouble());
       break;
     case BsonType.String:
     case BsonType.Symbol:
       this.SetToken(JsonToken.String, (object) this.ReadLengthString());
       break;
     case BsonType.Object:
       this.SetToken(JsonToken.StartObject);
       BsonReader.ContainerContext newContext1 = new BsonReader.ContainerContext(BsonType.Object);
       this.PushContext(newContext1);
       newContext1.Length = this.ReadInt32();
       break;
     case BsonType.Array:
       this.SetToken(JsonToken.StartArray);
       BsonReader.ContainerContext newContext2 = new BsonReader.ContainerContext(BsonType.Array);
       this.PushContext(newContext2);
       newContext2.Length = this.ReadInt32();
       break;
     case BsonType.Binary:
       this.SetToken(JsonToken.Bytes, (object) this.ReadBinary());
       break;
     case BsonType.Undefined:
       this.SetToken(JsonToken.Undefined);
       break;
     case BsonType.Oid:
       this.SetToken(JsonToken.Bytes, (object) this.ReadBytes(12));
       break;
     case BsonType.Boolean:
       this.SetToken(JsonToken.Boolean, (object) (bool) (Convert.ToBoolean(this.ReadByte()) ? 1 : 0));
       break;
     case BsonType.Date:
       DateTime dateTime1 = JsonConvert.ConvertJavaScriptTicksToDateTime(this.ReadInt64());
       DateTime dateTime2;
       switch (this.DateTimeKindHandling)
       {
         case DateTimeKind.Unspecified:
           dateTime2 = DateTime.SpecifyKind(dateTime1, DateTimeKind.Unspecified);
           break;
         case DateTimeKind.Local:
           dateTime2 = dateTime1.ToLocalTime();
           break;
         default:
           dateTime2 = dateTime1;
           break;
       }
       this.SetToken(JsonToken.Date, (object) dateTime2);
       break;
     case BsonType.Null:
       this.SetToken(JsonToken.Null);
       break;
     case BsonType.Regex:
       this.SetToken(JsonToken.String, (object) ("/" + this.ReadString() + "/" + this.ReadString()));
       break;
     case BsonType.Reference:
       this.SetToken(JsonToken.StartObject);
       this._bsonReaderState = BsonReader.BsonReaderState.ReferenceStart;
       break;
     case BsonType.Code:
       this.SetToken(JsonToken.String, (object) this.ReadLengthString());
       break;
     case BsonType.CodeWScope:
       this.SetToken(JsonToken.StartObject);
       this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeStart;
       break;
     case BsonType.Integer:
       this.SetToken(JsonToken.Integer, (object) (long) this.ReadInt32());
       break;
     case BsonType.TimeStamp:
     case BsonType.Long:
       this.SetToken(JsonToken.Integer, (object) this.ReadInt64());
       break;
     default:
       throw new ArgumentOutOfRangeException("type", "Unexpected BsonType value: " + (object) type);
   }
 }
Ejemplo n.º 20
0
 // Token: 0x060000AA RID: 170
 // RVA: 0x00029BD0 File Offset: 0x00027DD0
 private void ReadType(BsonType type)
 {
     switch (type)
     {
     case BsonType.Number:
     {
         double num = this.ReadDouble();
         if (this._floatParseHandling == FloatParseHandling.Decimal)
         {
             base.SetToken(JsonToken.Float, Convert.ToDecimal(num, CultureInfo.InvariantCulture));
             return;
         }
         base.SetToken(JsonToken.Float, num);
         return;
     }
     case BsonType.String:
     case BsonType.Symbol:
         base.SetToken(JsonToken.String, this.ReadLengthString());
         return;
     case BsonType.Object:
     {
         base.SetToken(JsonToken.StartObject);
         BsonReader.ContainerContext containerContext = new BsonReader.ContainerContext(BsonType.Object);
         this.PushContext(containerContext);
         containerContext.Length = this.ReadInt32();
         return;
     }
     case BsonType.Array:
     {
         base.SetToken(JsonToken.StartArray);
         BsonReader.ContainerContext containerContext2 = new BsonReader.ContainerContext(BsonType.Array);
         this.PushContext(containerContext2);
         containerContext2.Length = this.ReadInt32();
         return;
     }
     case BsonType.Binary:
     {
         BsonBinaryType bsonBinaryType;
         byte[] array = this.ReadBinary(out bsonBinaryType);
         object value = (bsonBinaryType != BsonBinaryType.Uuid) ? array : new Guid(array);
         base.SetToken(JsonToken.Bytes, value);
         return;
     }
     case BsonType.Undefined:
         base.SetToken(JsonToken.Undefined);
         return;
     case BsonType.Oid:
     {
         byte[] value2 = this.ReadBytes(12);
         base.SetToken(JsonToken.Bytes, value2);
         return;
     }
     case BsonType.Boolean:
     {
         bool flag = Convert.ToBoolean(this.ReadByte());
         base.SetToken(JsonToken.Boolean, flag);
         return;
     }
     case BsonType.Date:
     {
         long javaScriptTicks = this.ReadInt64();
         DateTime dateTime = DateTimeUtils.ConvertJavaScriptTicksToDateTime(javaScriptTicks);
         DateTime dateTime2;
         switch (this.DateTimeKindHandling)
         {
         case DateTimeKind.Unspecified:
             dateTime2 = DateTime.SpecifyKind(dateTime, DateTimeKind.Unspecified);
             goto IL_19D;
         case DateTimeKind.Local:
             dateTime2 = dateTime.ToLocalTime();
             goto IL_19D;
         }
         dateTime2 = dateTime;
         IL_19D:
         base.SetToken(JsonToken.Date, dateTime2);
         return;
     }
     case BsonType.Null:
         base.SetToken(JsonToken.Null);
         return;
     case BsonType.Regex:
     {
         string str = this.ReadString();
         string str2 = this.ReadString();
         string value3 = "/" + str + "/" + str2;
         base.SetToken(JsonToken.String, value3);
         return;
     }
     case BsonType.Reference:
         base.SetToken(JsonToken.StartObject);
         this._bsonReaderState = BsonReader.BsonReaderState.ReferenceStart;
         return;
     case BsonType.Code:
         base.SetToken(JsonToken.String, this.ReadLengthString());
         return;
     case BsonType.CodeWScope:
         base.SetToken(JsonToken.StartObject);
         this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeStart;
         return;
     case BsonType.Integer:
         base.SetToken(JsonToken.Integer, (long)this.ReadInt32());
         return;
     case BsonType.TimeStamp:
     case BsonType.Long:
         base.SetToken(JsonToken.Integer, this.ReadInt64());
         return;
     default:
         throw new ArgumentOutOfRangeException("type", "Unexpected BsonType value: " + type);
     }
 }
Ejemplo n.º 21
0
 private void PushContext(BsonReader.ContainerContext newContext)
 {
     this._stack.Add(newContext);
     this._currentContext = newContext;
 }
Ejemplo n.º 22
0
        private bool ReadNormal()
        {
            switch (base.CurrentState)
            {
            case JsonReader.State.Start:
            {
                JsonToken token = (!this._readRootValueAsArray) ? JsonToken.StartObject : JsonToken.StartArray;
                BsonType  type  = (!this._readRootValueAsArray) ? BsonType.Object : BsonType.Array;
                base.SetToken(token);
                BsonReader.ContainerContext containerContext = new BsonReader.ContainerContext(type);
                this.PushContext(containerContext);
                containerContext.Length = this.ReadInt32();
                return(true);
            }

            case JsonReader.State.Complete:
            case JsonReader.State.Closed:
                return(false);

            case JsonReader.State.Property:
                this.ReadType(this._currentElementType);
                return(true);

            case JsonReader.State.ObjectStart:
            case JsonReader.State.ArrayStart:
            case JsonReader.State.PostValue:
            {
                BsonReader.ContainerContext currentContext = this._currentContext;
                if (currentContext == null)
                {
                    return(false);
                }
                int num = currentContext.Length - 1;
                if (currentContext.Position < num)
                {
                    if (currentContext.Type == BsonType.Array)
                    {
                        this.ReadElement();
                        this.ReadType(this._currentElementType);
                        return(true);
                    }
                    base.SetToken(JsonToken.PropertyName, this.ReadElement());
                    return(true);
                }
                else
                {
                    if (currentContext.Position != num)
                    {
                        throw JsonReaderException.Create(this, "Read past end of current container context.");
                    }
                    if (this.ReadByte() != 0)
                    {
                        throw JsonReaderException.Create(this, "Unexpected end of object byte value.");
                    }
                    this.PopContext();
                    if (this._currentContext != null)
                    {
                        this.MovePosition(currentContext.Length);
                    }
                    JsonToken token2 = (currentContext.Type == BsonType.Object) ? JsonToken.EndObject : JsonToken.EndArray;
                    base.SetToken(token2);
                    return(true);
                }
                break;
            }

            case JsonReader.State.ConstructorStart:
            case JsonReader.State.Constructor:
            case JsonReader.State.Error:
            case JsonReader.State.Finished:
                return(false);
            }
            throw new ArgumentOutOfRangeException();
        }
Ejemplo n.º 23
0
        private void ReadType(BsonType type)
        {
            BsonBinaryType bsonBinaryType;
            DateTime       dateTime;
            object         guid;

            switch (type)
            {
            case BsonType.Number:
            {
                double num = this.ReadDouble();
                if (this._floatParseHandling != Newtonsoft.Json.FloatParseHandling.Decimal)
                {
                    base.SetToken(JsonToken.Float, num);
                    return;
                }
                base.SetToken(JsonToken.Float, Convert.ToDecimal(num, CultureInfo.InvariantCulture));
                return;
            }

            case BsonType.String:
            case BsonType.Symbol:
            {
                base.SetToken(JsonToken.String, this.ReadLengthString());
                return;
            }

            case BsonType.Object:
            {
                base.SetToken(JsonToken.StartObject);
                BsonReader.ContainerContext containerContext = new BsonReader.ContainerContext(BsonType.Object);
                this.PushContext(containerContext);
                containerContext.Length = this.ReadInt32();
                return;
            }

            case BsonType.Array:
            {
                base.SetToken(JsonToken.StartArray);
                BsonReader.ContainerContext containerContext1 = new BsonReader.ContainerContext(BsonType.Array);
                this.PushContext(containerContext1);
                containerContext1.Length = this.ReadInt32();
                return;
            }

            case BsonType.Binary:
            {
                byte[] numArray = this.ReadBinary(out bsonBinaryType);
                if (bsonBinaryType != BsonBinaryType.Uuid)
                {
                    guid = numArray;
                }
                else
                {
                    guid = new Guid(numArray);
                }
                base.SetToken(JsonToken.Bytes, guid);
                return;
            }

            case BsonType.Undefined:
            {
                base.SetToken(JsonToken.Undefined);
                return;
            }

            case BsonType.Oid:
            {
                base.SetToken(JsonToken.Bytes, this.ReadBytes(12));
                return;
            }

            case BsonType.Boolean:
            {
                bool flag = Convert.ToBoolean(this.ReadByte());
                base.SetToken(JsonToken.Boolean, flag);
                return;
            }

            case BsonType.Date:
            {
                DateTime     dateTime1            = DateTimeUtils.ConvertJavaScriptTicksToDateTime(this.ReadInt64());
                DateTimeKind dateTimeKindHandling = this.DateTimeKindHandling;
                if (dateTimeKindHandling == DateTimeKind.Unspecified)
                {
                    dateTime = DateTime.SpecifyKind(dateTime1, DateTimeKind.Unspecified);
                }
                else
                {
                    dateTime = (dateTimeKindHandling == DateTimeKind.Local ? dateTime1.ToLocalTime() : dateTime1);
                }
                base.SetToken(JsonToken.Date, dateTime);
                return;
            }

            case BsonType.Null:
            {
                base.SetToken(JsonToken.Null);
                return;
            }

            case BsonType.Regex:
            {
                string str  = this.ReadString();
                string str1 = this.ReadString();
                string str2 = string.Concat("/", str, "/", str1);
                base.SetToken(JsonToken.String, str2);
                return;
            }

            case BsonType.Reference:
            {
                base.SetToken(JsonToken.StartObject);
                this._bsonReaderState = BsonReader.BsonReaderState.ReferenceStart;
                return;
            }

            case BsonType.Code:
            {
                base.SetToken(JsonToken.String, this.ReadLengthString());
                return;
            }

            case BsonType.CodeWScope:
            {
                base.SetToken(JsonToken.StartObject);
                this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeStart;
                return;
            }

            case BsonType.Integer:
            {
                base.SetToken(JsonToken.Integer, (long)this.ReadInt32());
                return;
            }

            case BsonType.TimeStamp:
            case BsonType.Long:
            {
                base.SetToken(JsonToken.Integer, this.ReadInt64());
                return;
            }
            }
            throw new ArgumentOutOfRangeException("type", string.Concat("Unexpected BsonType value: ", type));
        }
Ejemplo n.º 24
0
        private void ReadType(BsonType type)
        {
            switch (type)
            {
            case BsonType.Number:
            {
                double num = this.ReadDouble();
                if (this._floatParseHandling == FloatParseHandling.Decimal)
                {
                    base.SetToken(JsonToken.Float, Convert.ToDecimal(num, CultureInfo.InvariantCulture));
                    return;
                }
                base.SetToken(JsonToken.Float, num);
                return;
            }

            case BsonType.String:
            case BsonType.Symbol:
                base.SetToken(JsonToken.String, this.ReadLengthString());
                return;

            case BsonType.Object:
            {
                base.SetToken(JsonToken.StartObject);
                BsonReader.ContainerContext containerContext = new BsonReader.ContainerContext(BsonType.Object);
                this.PushContext(containerContext);
                containerContext.Length = this.ReadInt32();
                return;
            }

            case BsonType.Array:
            {
                base.SetToken(JsonToken.StartArray);
                BsonReader.ContainerContext containerContext2 = new BsonReader.ContainerContext(BsonType.Array);
                this.PushContext(containerContext2);
                containerContext2.Length = this.ReadInt32();
                return;
            }

            case BsonType.Binary:
                base.SetToken(JsonToken.Bytes, this.ReadBinary());
                return;

            case BsonType.Undefined:
                base.SetToken(JsonToken.Undefined);
                return;

            case BsonType.Oid:
            {
                byte[] value = this.ReadBytes(12);
                base.SetToken(JsonToken.Bytes, value);
                return;
            }

            case BsonType.Boolean:
            {
                bool flag = Convert.ToBoolean(this.ReadByte());
                base.SetToken(JsonToken.Boolean, flag);
                return;
            }

            case BsonType.Date:
            {
                long     javaScriptTicks = this.ReadInt64();
                DateTime dateTime        = DateTimeUtils.ConvertJavaScriptTicksToDateTime(javaScriptTicks);
                DateTime dateTime2;
                switch (this.DateTimeKindHandling)
                {
                case DateTimeKind.Unspecified:
                    dateTime2 = DateTime.SpecifyKind(dateTime, DateTimeKind.Unspecified);
                    goto IL_184;

                case DateTimeKind.Local:
                    dateTime2 = dateTime.ToLocalTime();
                    goto IL_184;
                }
                dateTime2 = dateTime;
IL_184:
                base.SetToken(JsonToken.Date, dateTime2);
                return;
            }

            case BsonType.Null:
                base.SetToken(JsonToken.Null);
                return;

            case BsonType.Regex:
            {
                string str    = this.ReadString();
                string str2   = this.ReadString();
                string value2 = "/" + str + "/" + str2;
                base.SetToken(JsonToken.String, value2);
                return;
            }

            case BsonType.Reference:
                base.SetToken(JsonToken.StartObject);
                this._bsonReaderState = BsonReader.BsonReaderState.ReferenceStart;
                return;

            case BsonType.Code:
                base.SetToken(JsonToken.String, this.ReadLengthString());
                return;

            case BsonType.CodeWScope:
                base.SetToken(JsonToken.StartObject);
                this._bsonReaderState = BsonReader.BsonReaderState.CodeWScopeStart;
                return;

            case BsonType.Integer:
                base.SetToken(JsonToken.Integer, (long)this.ReadInt32());
                return;

            case BsonType.TimeStamp:
            case BsonType.Long:
                base.SetToken(JsonToken.Integer, this.ReadInt64());
                return;

            default:
                throw new ArgumentOutOfRangeException("type", "Unexpected BsonType value: " + type);
            }
        }