Exemplo n.º 1
0
        private string method_35(JsonWriter jsonWriter_0, DictionaryEntry dictionaryEntry_0, JsonContract jsonContract_1, out bool bool_1)
        {
            string str;
            object key = dictionaryEntry_0.Key;
            JsonPrimitiveContract contract = jsonContract_1 as JsonPrimitiveContract;

            if (contract != null)
            {
                if ((contract.Enum17_0 != Enum17.DateTime) && (contract.Enum17_0 != Enum17.DateTimeNullable))
                {
                    if ((contract.Enum17_0 != Enum17.DateTimeOffset) && (contract.Enum17_0 != Enum17.DateTimeOffsetNullable))
                    {
                        bool_1 = true;
                        return(Convert.ToString(key, CultureInfo.InvariantCulture));
                    }
                    bool_1 = false;
                    StringWriter writer2 = new StringWriter(CultureInfo.InvariantCulture);
                    Class184.smethod_21(writer2, (DateTimeOffset)key, jsonWriter_0.DateFormatHandling, jsonWriter_0.DateFormatString, jsonWriter_0.Culture);
                    return(writer2.ToString());
                }
                bool_1 = false;
                StringWriter writer = new StringWriter(CultureInfo.InvariantCulture);
                Class184.smethod_16(writer, (DateTime)key, jsonWriter_0.DateFormatHandling, jsonWriter_0.DateFormatString, jsonWriter_0.Culture);
                return(writer.ToString());
            }
            if (smethod_0(key, key.GetType(), out str))
            {
                bool_1 = true;
                return(str);
            }
            bool_1 = true;
            return(key.ToString());
        }
Exemplo n.º 2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            Type type = Class194.smethod_10(objectType) ? Nullable.GetUnderlyingType(objectType) : objectType;

            if (reader.JsonToken_0 == JsonToken.Null)
            {
                if (!Class194.smethod_9(objectType))
                {
                    throw JsonSerializationException.smethod_1(reader, "Cannot convert null value to {0}.".smethod_0(CultureInfo.InvariantCulture, objectType));
                }
                return(null);
            }
            if ((reader.JsonToken_0 != JsonToken.StartConstructor) || !string.Equals(reader.Object_0.ToString(), "Date", StringComparison.Ordinal))
            {
                throw JsonSerializationException.smethod_1(reader, "Unexpected token or value when parsing date. Token: {0}, Value: {1}".smethod_1(CultureInfo.InvariantCulture, reader.JsonToken_0, reader.Object_0));
            }
            reader.Read();
            if (reader.JsonToken_0 != JsonToken.Integer)
            {
                throw JsonSerializationException.smethod_1(reader, "Unexpected token parsing date. Expected Integer, got {0}.".smethod_0(CultureInfo.InvariantCulture, reader.JsonToken_0));
            }
            long     num      = (long)reader.Object_0;
            DateTime dateTime = Class184.smethod_11(num);

            reader.Read();
            if (reader.JsonToken_0 != JsonToken.EndConstructor)
            {
                throw JsonSerializationException.smethod_1(reader, "Unexpected token parsing date. Expected EndConstructor, got {0}.".smethod_0(CultureInfo.InvariantCulture, reader.JsonToken_0));
            }
            if (!(type == typeof(DateTimeOffset)))
            {
                return(dateTime);
            }
            return(new DateTimeOffset(dateTime));
        }
Exemplo n.º 3
0
 private string method_9(JsonReader jsonReader_0)
 {
     if (jsonReader_0.JsonToken_0 == JsonToken.String)
     {
         return(jsonReader_0.Object_0.ToString());
     }
     if (jsonReader_0.JsonToken_0 == JsonToken.Integer)
     {
         return(XmlConvert.ToString(Convert.ToInt64(jsonReader_0.Object_0, CultureInfo.InvariantCulture)));
     }
     if (jsonReader_0.JsonToken_0 == JsonToken.Float)
     {
         return(XmlConvert.ToString(Convert.ToDouble(jsonReader_0.Object_0, CultureInfo.InvariantCulture)));
     }
     if (jsonReader_0.JsonToken_0 == JsonToken.Boolean)
     {
         return(XmlConvert.ToString(Convert.ToBoolean(jsonReader_0.Object_0, CultureInfo.InvariantCulture)));
     }
     if (jsonReader_0.JsonToken_0 == JsonToken.Date)
     {
         DateTime time = Convert.ToDateTime(jsonReader_0.Object_0, CultureInfo.InvariantCulture);
         return(XmlConvert.ToString(time, Class184.smethod_1(time.Kind)));
     }
     if (jsonReader_0.JsonToken_0 != JsonToken.Null)
     {
         throw JsonSerializationException.smethod_1(jsonReader_0, "Cannot get an XML string value from token type '{0}'.".smethod_0(CultureInfo.InvariantCulture, jsonReader_0.JsonToken_0));
     }
     return(null);
 }
Exemplo n.º 4
0
 public static string ToString(DateTimeOffset value, DateFormatHandling format)
 {
     using (StringWriter writer = Class198.smethod_6(0x40))
     {
         writer.Write('"');
         Class184.smethod_21(writer, value, format, null, CultureInfo.InvariantCulture);
         writer.Write('"');
         return(writer.ToString());
     }
 }
Exemplo n.º 5
0
 private void method_16(char char_3)
 {
     this.int_1++;
     this.method_17();
     this.method_22(char_3);
     if (base.enum14_0 == Enum14.ReadAsBytes)
     {
         byte[] buffer;
         if (this.struct29_0.Int32_1 == 0)
         {
             buffer = new byte[0];
         }
         else
         {
             buffer = Convert.FromBase64CharArray(this.struct29_0.Char_0, this.struct29_0.Int32_0, this.struct29_0.Int32_1);
         }
         base.SetToken(JsonToken.Bytes, buffer);
     }
     else if (base.enum14_0 == Enum14.ReadAsString)
     {
         string str = this.struct29_0.ToString();
         base.SetToken(JsonToken.String, str);
         base.char_0 = char_3;
     }
     else
     {
         string str2 = this.struct29_0.ToString();
         if (base.dateParseHandling_0 != DateParseHandling.None)
         {
             DateParseHandling dateTime;
             object            obj2;
             if (base.enum14_0 == Enum14.ReadAsDateTime)
             {
                 dateTime = DateParseHandling.DateTime;
             }
             else if (base.enum14_0 == Enum14.ReadAsDateTimeOffset)
             {
                 dateTime = DateParseHandling.DateTimeOffset;
             }
             else
             {
                 dateTime = base.dateParseHandling_0;
             }
             if (Class184.smethod_13(str2, dateTime, base.DateTimeZoneHandling, out obj2))
             {
                 base.SetToken(JsonToken.Date, obj2);
                 return;
             }
         }
         base.SetToken(JsonToken.String, str2);
         base.char_0 = char_3;
     }
 }
Exemplo n.º 6
0
        public static string ToString(DateTime value, DateFormatHandling format, DateTimeZoneHandling timeZoneHandling)
        {
            DateTime time = Class184.smethod_2(value, timeZoneHandling);

            using (StringWriter writer = Class198.smethod_6(0x40))
            {
                writer.Write('"');
                Class184.smethod_16(writer, time, format, null, CultureInfo.InvariantCulture);
                writer.Write('"');
                return(writer.ToString());
            }
        }
Exemplo n.º 7
0
    // Token: 0x0600052C RID: 1324 RVA: 0x0002C3AC File Offset: 0x0002A5AC
    public string method_1()
    {
        string text;

        if (this.method_0(out text))
        {
            return(text);
        }
        object obj = Struct42.object_0;

        lock (obj)
        {
            if (this.method_0(out text))
            {
                return(text);
            }
            Class184 class184_ = this.class58_0.class12_0.class184_0;
            object   obj2      = class184_.object_0;
            byte[]   byte_;
            bool     bool_;
            lock (obj2)
            {
                byte_ = class184_.byte_0;
                bool_ = class184_.bool_0;
                if (class184_.bool_1)
                {
                    if (byte_ == null)
                    {
                        throw new Exception(Class185.smethod_0(537694803));
                    }
                }
                else
                {
                    WeakReference weakReference_ = this.class58_0.class12_0.weakReference_1;
                    string        text2          = ((weakReference_ != null) ? weakReference_.Target : null) as string;
                    if (text2 == null)
                    {
                        throw new Exception(Class185.smethod_0(537694608));
                    }
                    text = string.Copy(text2);
                    Class125.smethod_3(text2);
                }
                class184_.bool_1 = true;
            }
            if (text == null)
            {
                text = Class125.smethod_2(byte_, bool_);
            }
            this.method_2(text);
        }
        return(text);
    }
Exemplo n.º 8
0
 public Class194(int int2, bool bool1)
 {
     if (int2 == -1)
     {
         int2 = 6;
     }
     else if (int2 < 0 || int2 > 9)
     {
         throw new ArgumentOutOfRangeException("level");
     }
     _class1890 = new Class189();
     _class1840 = new Class184(_class1890);
     _bool0     = bool1;
     method_8(Enum29.Const0);
     method_7(int2);
     method_0();
 }
Exemplo n.º 9
0
 public Class194(int int_2, bool bool_1)
 {
     if (int_2 == -1)
     {
         int_2 = 6;
     }
     else if (int_2 < 0 || int_2 > 9)
     {
         throw new ArgumentOutOfRangeException("level");
     }
     this.class189_0 = new Class189();
     this.class184_0 = new Class184(this.class189_0);
     this.bool_0     = bool_1;
     this.method_8(Enum29.const_0);
     this.method_7(int_2);
     this.method_0();
 }
Exemplo n.º 10
0
 public override void WriteValue(DateTimeOffset value)
 {
     base.method_17(JsonToken.Date);
     if (string.IsNullOrEmpty(base.DateFormatString))
     {
         this.method_23();
         int count = 0;
         count                = 1;
         this.char_2[0]       = this.char_1;
         count                = Class184.smethod_17(this.char_2, 1, (base.DateFormatHandling == DateFormatHandling.IsoDateFormat) ? value.DateTime : value.UtcDateTime, new TimeSpan?(value.Offset), DateTimeKind.Local, base.DateFormatHandling);
         this.char_2[count++] = this.char_1;
         this.textWriter_0.Write(this.char_2, 0, count);
     }
     else
     {
         this.textWriter_0.Write(this.char_1);
         this.textWriter_0.Write(value.ToString(base.DateFormatString, base.Culture));
         this.textWriter_0.Write(this.char_1);
     }
 }
Exemplo n.º 11
0
 internal DateTime?method_9()
 {
     this.enum14_0 = Enum14.ReadAsDateTime;
     while (this.Newtonsoft.Json.JsonReader.‪​‮‫​​​‏‪​‭‎‫​‌‏‫‪‫‭‮‬‬‭​‏‭‫‎‍‮())
     {
         if (this.JsonToken_0 != JsonToken.Comment)
         {
             if (this.JsonToken_0 == JsonToken.Date)
             {
                 return(new DateTime?((DateTime)this.Object_0));
             }
             if (this.JsonToken_0 != JsonToken.Null)
             {
                 if (this.JsonToken_0 == JsonToken.String)
                 {
                     DateTime time;
                     string   str = (string)this.Object_0;
                     if (string.IsNullOrEmpty(str))
                     {
                         this.SetToken(JsonToken.Null);
                         return(null);
                     }
                     if (!DateTime.TryParse(str, this.Culture, DateTimeStyles.RoundtripKind, out time))
                     {
                         throw JsonReaderException.smethod_1(this, "Could not convert string to DateTime: {0}.".smethod_0(CultureInfo.InvariantCulture, this.Object_0));
                     }
                     time = Class184.smethod_2(time, this.DateTimeZoneHandling);
                     this.SetToken(JsonToken.Date, time);
                     return(new DateTime?(time));
                 }
                 if (this.JsonToken_0 != JsonToken.EndArray)
                 {
                     throw JsonReaderException.smethod_1(this, "Error reading date. Unexpected token: {0}.".smethod_0(CultureInfo.InvariantCulture, this.JsonToken_0));
                 }
             }
             return(null);
         }
     }
     this.SetToken(JsonToken.None);
     return(null);
 }
Exemplo n.º 12
0
 public override void WriteValue(DateTime value)
 {
     base.method_17(JsonToken.Date);
     value = Class184.smethod_2(value, base.DateTimeZoneHandling);
     if (string.IsNullOrEmpty(base.DateFormatString))
     {
         this.method_23();
         int count = 0;
         count                = 1;
         this.char_2[0]       = this.char_1;
         count                = Class184.smethod_17(this.char_2, 1, value, null, value.Kind, base.DateFormatHandling);
         this.char_2[count++] = this.char_1;
         this.textWriter_0.Write(this.char_2, 0, count);
     }
     else
     {
         this.textWriter_0.Write(this.char_1);
         this.textWriter_0.Write(value.ToString(base.DateFormatString, base.Culture));
         this.textWriter_0.Write(this.char_1);
     }
 }
Exemplo n.º 13
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            long num;

            if (value is DateTime)
            {
                num = Class184.smethod_8(((DateTime)value).ToUniversalTime());
            }
            else
            {
                if (!(value is DateTimeOffset))
                {
                    throw new JsonSerializationException("Expected date object value.");
                }
                DateTimeOffset offset = (DateTimeOffset)value;
                num = Class184.smethod_8(offset.ToUniversalTime().UtcDateTime);
            }
            writer.WriteStartConstructor("Date");
            writer.WriteValue(num);
            writer.WriteEndConstructor();
        }
Exemplo n.º 14
0
        private void method_6(JsonReader jsonReader_0)
        {
            if (!jsonReader_0.Read())
            {
                throw JsonWriterException.smethod_1(this, "Unexpected end when reading date constructor.", null);
            }
            if (jsonReader_0.JsonToken_0 != JsonToken.Integer)
            {
                throw JsonWriterException.smethod_1(this, "Unexpected token when reading date constructor. Expected Integer, got " + jsonReader_0.JsonToken_0, null);
            }
            long     num  = (long)jsonReader_0.Object_0;
            DateTime time = Class184.smethod_11(num);

            if (!jsonReader_0.Read())
            {
                throw JsonWriterException.smethod_1(this, "Unexpected end when reading date constructor.", null);
            }
            if (jsonReader_0.JsonToken_0 != JsonToken.EndConstructor)
            {
                throw JsonWriterException.smethod_1(this, "Unexpected token when reading date constructor. Expected EndConstructor, got " + jsonReader_0.JsonToken_0, null);
            }
            this.WriteValue(time);
        }
Exemplo n.º 15
0
 // Token: 0x06000337 RID: 823 RVA: 0x000049C1 File Offset: 0x00002BC1
 public Class83(string string_1, Class12 class12_1, Class184 class184_1)
 {
     this.string_0   = string_1;
     this.class12_0  = class12_1;
     this.class184_0 = class184_1;
 }
Exemplo n.º 16
0
 public override void WriteValue(DateTime value)
 {
     base.WriteValue(value);
     value = Class184.smethod_2(value, base.DateTimeZoneHandling);
     this.method_22(value, JsonToken.Date);
 }
 public override void Visit(Class184 c) { }
Exemplo n.º 18
0
        private void method_21(Enum11 enum11_1)
        {
            DateTime time;
            DateTime time2;

            switch (enum11_1)
            {
            case Enum11.Number:
            {
                double num = this.method_29();
                if (base.floatParseHandling_0 != FloatParseHandling.Decimal)
                {
                    base.SetToken(JsonToken.Float, num);
                    return;
                }
                base.SetToken(JsonToken.Float, Convert.ToDecimal(num, CultureInfo.InvariantCulture));
                return;
            }

            case Enum11.String:
            case Enum11.Symbol:
                base.SetToken(JsonToken.String, this.method_24());
                return;

            case Enum11.Object:
            {
                base.SetToken(JsonToken.StartObject);
                Class69 class2 = new Class69(Enum11.Object);
                this.method_19(class2);
                class2.int_0 = this.method_30();
                return;
            }

            case Enum11.Array:
            {
                base.SetToken(JsonToken.StartArray);
                Class69 class3 = new Class69(Enum11.Array);
                this.method_19(class3);
                class3.int_0 = this.method_30();
                return;
            }

            case Enum11.Binary:
                base.SetToken(JsonToken.Bytes, this.method_22());
                return;

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

            case Enum11.Oid:
            {
                byte[] buffer = this.method_34(12);
                base.SetToken(JsonToken.Bytes, buffer);
                return;
            }

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

            case Enum11.Date:
                time = Class184.smethod_11(this.method_31());
                switch (this.DateTimeKindHandling)
                {
                case DateTimeKind.Unspecified:
                    time2 = DateTime.SpecifyKind(time, DateTimeKind.Unspecified);
                    goto Label_017F;

                case DateTimeKind.Local:
                    time2 = time.ToLocalTime();
                    goto Label_017F;
                }
                break;

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

            case Enum11.Regex:
            {
                string str  = this.method_23();
                string str2 = this.method_23();
                string str3 = "/" + str + "/" + str2;
                base.SetToken(JsonToken.String, str3);
                return;
            }

            case Enum11.Reference:
                base.SetToken(JsonToken.StartObject);
                this.enum10_0 = Enum10.ReferenceStart;
                return;

            case Enum11.Code:
                base.SetToken(JsonToken.String, this.method_24());
                return;

            case Enum11.CodeWScope:
                base.SetToken(JsonToken.StartObject);
                this.enum10_0 = Enum10.CodeWScopeStart;
                return;

            case Enum11.Integer:
                base.SetToken(JsonToken.Integer, (long)this.method_30());
                return;

            case Enum11.TimeStamp:
            case Enum11.Long:
                base.SetToken(JsonToken.Integer, this.method_31());
                return;

            default:
                throw new ArgumentOutOfRangeException("type", "Unexpected BsonType value: " + enum11_1);
            }
            time2 = time;
Label_017F:
            base.SetToken(JsonToken.Date, time2);
        }
Exemplo n.º 19
0
        private void method_3(Class70 class70_0)
        {
            long     num2;
            DateTime time;

            switch (class70_0.Enum11_0)
            {
            case Enum11.Number:
            {
                Class73 class8 = (Class73)class70_0;
                this.binaryWriter_0.Write(Convert.ToDouble(class8.Object_0, CultureInfo.InvariantCulture));
                return;
            }

            case Enum11.String:
            {
                Class74 class9 = (Class74)class70_0;
                this.method_4((string)class9.Object_0, class9.Int32_1, new int?(class9.Int32_0 - 4));
                return;
            }

            case Enum11.Object:
            {
                Class71 class2 = (Class71)class70_0;
                this.binaryWriter_0.Write(class2.Int32_0);
                foreach (Class77 class3 in class2)
                {
                    this.binaryWriter_0.Write((sbyte)class3.Class70_0.Enum11_0);
                    int?nullable = null;
                    this.method_4((string)class3.Name.Object_0, class3.Name.Int32_1, nullable);
                    this.method_3(class3.Class70_0);
                }
                this.binaryWriter_0.Write((byte)0);
                return;
            }

            case Enum11.Array:
            {
                Class72 class4 = (Class72)class70_0;
                this.binaryWriter_0.Write(class4.Int32_0);
                ulong num = 0L;
                foreach (Class70 class5 in class4)
                {
                    this.binaryWriter_0.Write((sbyte)class5.Enum11_0);
                    int?nullable2 = null;
                    this.method_4(num.ToString(CultureInfo.InvariantCulture), Class192.smethod_0(num), nullable2);
                    this.method_3(class5);
                    num += (ulong)1L;
                }
                this.binaryWriter_0.Write((byte)0);
                return;
            }

            case Enum11.Binary:
            {
                Class75 class12 = (Class75)class70_0;
                byte[]  buffer  = (byte[])class12.Object_0;
                this.binaryWriter_0.Write(buffer.Length);
                this.binaryWriter_0.Write((byte)class12.Enum9_0);
                this.binaryWriter_0.Write(buffer);
                return;
            }

            case Enum11.Undefined:
            case Enum11.Null:
                return;

            case Enum11.Oid:
            {
                Class73 class13 = (Class73)class70_0;
                byte[]  buffer2 = (byte[])class13.Object_0;
                this.binaryWriter_0.Write(buffer2);
                return;
            }

            case Enum11.Boolean:
            {
                Class73 class10 = (Class73)class70_0;
                this.binaryWriter_0.Write((bool)class10.Object_0);
                return;
            }

            case Enum11.Date:
            {
                Class73 class11 = (Class73)class70_0;
                num2 = 0L;
                if (!(class11.Object_0 is DateTime))
                {
                    DateTimeOffset offset = (DateTimeOffset)class11.Object_0;
                    num2 = Class184.smethod_7(offset.UtcDateTime, offset.Offset);
                    goto Label_02FE;
                }
                time = (DateTime)class11.Object_0;
                if (this.DateTimeKind_0 != DateTimeKind.Utc)
                {
                    if (this.DateTimeKind_0 == DateTimeKind.Local)
                    {
                        time = time.ToLocalTime();
                    }
                    break;
                }
                time = time.ToUniversalTime();
                break;
            }

            case Enum11.Regex:
            {
                Class76 class14 = (Class76)class70_0;
                this.method_4((string)class14.Class74_0.Object_0, class14.Class74_0.Int32_1, null);
                this.method_4((string)class14.Class74_1.Object_0, class14.Class74_1.Int32_1, null);
                return;
            }

            case Enum11.Integer:
            {
                Class73 class6 = (Class73)class70_0;
                this.binaryWriter_0.Write(Convert.ToInt32(class6.Object_0, CultureInfo.InvariantCulture));
                return;
            }

            case Enum11.Long:
            {
                Class73 class7 = (Class73)class70_0;
                this.binaryWriter_0.Write(Convert.ToInt64(class7.Object_0, CultureInfo.InvariantCulture));
                return;
            }

            default:
                throw new ArgumentOutOfRangeException("t", "Unexpected token when writing BSON: {0}".smethod_0(CultureInfo.InvariantCulture, class70_0.Enum11_0));
            }
            num2 = Class184.smethod_9(time, false);
Label_02FE:
            this.binaryWriter_0.Write(num2);
        }
 public abstract void Visit(Class184 c);