示例#1
0
 protected JsonReader()
 {
     this._currentState         = JsonReader.State.Start;
     this._dateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.RoundtripKind;
     this._dateParseHandling    = Newtonsoft.Json.DateParseHandling.DateTime;
     this._floatParseHandling   = Newtonsoft.Json.FloatParseHandling.Double;
     this.CloseInput            = true;
 }
        private void SetupReader(JsonReader reader, out CultureInfo previousCulture, out Newtonsoft.Json.DateTimeZoneHandling?previousDateTimeZoneHandling, out Newtonsoft.Json.DateParseHandling?previousDateParseHandling, out Newtonsoft.Json.FloatParseHandling?previousFloatParseHandling, out int?previousMaxDepth, out string previousDateFormatString)
        {
            JsonTextReader          nameTable;
            DefaultContractResolver defaultContractResolver;

            if (this._culture == null || this._culture.Equals(reader.Culture))
            {
                previousCulture = null;
            }
            else
            {
                previousCulture = reader.Culture;
                reader.Culture  = this._culture;
            }
            if (this._dateTimeZoneHandling.HasValue)
            {
                Newtonsoft.Json.DateTimeZoneHandling dateTimeZoneHandling = reader.DateTimeZoneHandling;
                Newtonsoft.Json.DateTimeZoneHandling?nullable             = this._dateTimeZoneHandling;
                if ((dateTimeZoneHandling == nullable.GetValueOrDefault() ? nullable.HasValue : false))
                {
                    goto Label1;
                }
                previousDateTimeZoneHandling = new Newtonsoft.Json.DateTimeZoneHandling?(reader.DateTimeZoneHandling);
                reader.DateTimeZoneHandling  = this._dateTimeZoneHandling.GetValueOrDefault();
                goto Label0;
            }
Label1:
            previousDateTimeZoneHandling = null;
Label0:
            if (this._dateParseHandling.HasValue)
            {
                Newtonsoft.Json.DateParseHandling dateParseHandling = reader.DateParseHandling;
                Newtonsoft.Json.DateParseHandling?nullable1         = this._dateParseHandling;
                if ((dateParseHandling == nullable1.GetValueOrDefault() ? nullable1.HasValue : false))
                {
                    goto Label3;
                }
                previousDateParseHandling = new Newtonsoft.Json.DateParseHandling?(reader.DateParseHandling);
                reader.DateParseHandling  = this._dateParseHandling.GetValueOrDefault();
                goto Label2;
            }
Label3:
            previousDateParseHandling = null;
Label2:
            if (this._floatParseHandling.HasValue)
            {
                Newtonsoft.Json.FloatParseHandling floatParseHandling = reader.FloatParseHandling;
                Newtonsoft.Json.FloatParseHandling?nullable2          = this._floatParseHandling;
                if ((floatParseHandling == nullable2.GetValueOrDefault() ? nullable2.HasValue : false))
                {
                    goto Label5;
                }
                previousFloatParseHandling = new Newtonsoft.Json.FloatParseHandling?(reader.FloatParseHandling);
                reader.FloatParseHandling  = this._floatParseHandling.GetValueOrDefault();
                goto Label4;
            }
Label5:
            previousFloatParseHandling = null;
Label4:
            if (this._maxDepthSet)
            {
                int?maxDepth  = reader.MaxDepth;
                int?nullable3 = this._maxDepth;
                if ((maxDepth.GetValueOrDefault() == nullable3.GetValueOrDefault() ? maxDepth.HasValue == nullable3.HasValue : false))
                {
                    previousMaxDepth = null;
                    if (!this._dateFormatStringSet || !(reader.DateFormatString != this._dateFormatString))
                    {
                        previousDateFormatString = null;
                    }
                    else
                    {
                        previousDateFormatString = reader.DateFormatString;
                        reader.DateFormatString  = this._dateFormatString;
                    }
                    nameTable = reader as JsonTextReader;
                    if (nameTable != null)
                    {
                        defaultContractResolver = this._contractResolver as DefaultContractResolver;
                        if (defaultContractResolver != null)
                        {
                            nameTable.NameTable = defaultContractResolver.GetState().NameTable;
                        }
                    }
                    return;
                }
                previousMaxDepth = reader.MaxDepth;
                reader.MaxDepth  = this._maxDepth;
                if (!this._dateFormatStringSet || !(reader.DateFormatString != this._dateFormatString))
                {
                    previousDateFormatString = null;
                }
                else
                {
                    previousDateFormatString = reader.DateFormatString;
                    reader.DateFormatString  = this._dateFormatString;
                }
                nameTable = reader as JsonTextReader;
                if (nameTable != null)
                {
                    defaultContractResolver = this._contractResolver as DefaultContractResolver;
                    if (defaultContractResolver != null)
                    {
                        nameTable.NameTable = defaultContractResolver.GetState().NameTable;
                    }
                }
                return;
            }
            previousMaxDepth = null;
            if (!this._dateFormatStringSet || !(reader.DateFormatString != this._dateFormatString))
            {
                previousDateFormatString = null;
            }
            else
            {
                previousDateFormatString = reader.DateFormatString;
                reader.DateFormatString  = this._dateFormatString;
            }
            nameTable = reader as JsonTextReader;
            if (nameTable != null)
            {
                defaultContractResolver = this._contractResolver as DefaultContractResolver;
                if (defaultContractResolver != null)
                {
                    nameTable.NameTable = defaultContractResolver.GetState().NameTable;
                }
            }
        }