Example #1
0
        // Token: 0x06000AB3 RID: 2739 RVA: 0x0003E1F4 File Offset: 0x0003C3F4
        private void xmethod_1851(Class_287 arg_0)
        {
            switch (arg_0.prop_0)
            {
            case Class_295.Number:
            {
                Class_290 class_ = (Class_290)arg_0;
                this.field_1.Write(Convert.ToDouble(class_.prop_0, CultureInfo.InvariantCulture));
                return;
            }

            case Class_295.String:
            {
                Class_291 class_2 = (Class_291)arg_0;
                this.tmethod_1852((string)class_2.prop_0, class_2.prop_0, new int?(class_2.prop_2 - 4));
                return;
            }

            case Class_295.Object:
            {
                Class_288 class_3 = (Class_288)arg_0;
                this.field_1.Write(class_3.prop_2);
                using (IEnumerator <Class_294> enumerator = class_3.dmethod_1956())
                {
                    while (enumerator.MoveNext())
                    {
                        Class_294 class_4 = enumerator.Current;
                        this.field_1.Write((sbyte)class_4.prop_1.prop_0);
                        this.tmethod_1852((string)class_4.prop_0.prop_0, class_4.prop_0.prop_0, null);
                        this.xmethod_1851(class_4.prop_1);
                    }
                }
                this.field_1.Write(0);
                return;
            }

            case Class_295.Array:
            {
                Class_289 class_5 = (Class_289)arg_0;
                this.field_1.Write(class_5.prop_2);
                ulong num = 0UL;
                using (IEnumerator <Class_287> enumerator2 = class_5.smethod_1960())
                {
                    while (enumerator2.MoveNext())
                    {
                        Class_287 class_6 = enumerator2.Current;
                        this.field_1.Write((sbyte)class_6.prop_0);
                        this.tmethod_1852(num.ToString(CultureInfo.InvariantCulture), Class_511.IntLength(num), null);
                        this.xmethod_1851(class_6);
                        num += 1UL;
                    }
                }
                this.field_1.Write(0);
                return;
            }

            case Class_295.Binary:
            {
                Class_292 class_7 = (Class_292)arg_0;
                byte[]    array   = (byte[])class_7.prop_0;
                this.field_1.Write(array.Length);
                this.field_1.Write((byte)class_7.prop_0);
                this.field_1.Write(array);
                return;
            }

            case Class_295.Undefined:
            case Class_295.Null:
                return;

            case Class_295.Oid:
            {
                Class_290 class_8 = (Class_290)arg_0;
                byte[]    buffer  = (byte[])class_8.prop_0;
                this.field_1.Write(buffer);
                return;
            }

            case Class_295.Boolean:
            {
                Class_290 class_9 = (Class_290)arg_0;
                this.field_1.Write((bool)class_9.prop_0);
                return;
            }

            case Class_295.Date:
            {
                Class_290 class_10 = (Class_290)arg_0;
                long      value;
                if (class_10.prop_0 is DateTime)
                {
                    DateTime dateTime = (DateTime)class_10.prop_0;
                    if (this.prop_0 == DateTimeKind.Utc)
                    {
                        dateTime = dateTime.ToUniversalTime();
                    }
                    else if (this.prop_0 == DateTimeKind.Local)
                    {
                        dateTime = dateTime.ToLocalTime();
                    }
                    value = Class_502.ConvertDateTimeToJavaScriptTicks(dateTime, false);
                }
                else
                {
                    DateTimeOffset dateTimeOffset = (DateTimeOffset)class_10.prop_0;
                    value = Class_502.ConvertDateTimeToJavaScriptTicks(dateTimeOffset.UtcDateTime, dateTimeOffset.Offset);
                }
                this.field_1.Write(value);
                return;
            }

            case Class_295.Regex:
            {
                Class_293 class_11 = (Class_293)arg_0;
                this.tmethod_1852((string)class_11.prop_0.prop_0, class_11.prop_0.prop_0, null);
                this.tmethod_1852((string)class_11.prop_1.prop_0, class_11.prop_1.prop_0, null);
                return;
            }

            case Class_295.Integer:
            {
                Class_290 class_12 = (Class_290)arg_0;
                this.field_1.Write(Convert.ToInt32(class_12.prop_0, CultureInfo.InvariantCulture));
                return;
            }

            case Class_295.Long:
            {
                Class_290 class_13 = (Class_290)arg_0;
                this.field_1.Write(Convert.ToInt64(class_13.prop_0, CultureInfo.InvariantCulture));
                return;
            }
            }
            throw new ArgumentOutOfRangeException("t", "Unexpected token when writing BSON: {0}".FormatWith(CultureInfo.InvariantCulture, arg_0.prop_0));
        }
Example #2
0
        // Token: 0x06000AB8 RID: 2744 RVA: 0x0003E6E0 File Offset: 0x0003C8E0
        private int dmethod_1856(Class_287 arg_0)
        {
            switch (arg_0.prop_0)
            {
            case Class_295.Number:
                return(8);

            case Class_295.String:
            {
                Class_291 class_ = (Class_291)arg_0;
                string    text   = (string)class_.prop_0;
                class_.prop_0 = ((text != null) ? Class_284.field_0.GetByteCount(text) : 0);
                class_.prop_2 = this.vmethod_1855(class_.prop_0, class_.prop_1);
                return(class_.prop_2);
            }

            case Class_295.Object:
            {
                Class_288 class_2 = (Class_288)arg_0;
                int       num     = 4;
                using (IEnumerator <Class_294> enumerator = class_2.dmethod_1956())
                {
                    while (enumerator.MoveNext())
                    {
                        Class_294 class_3 = enumerator.Current;
                        int       num2    = 1;
                        num2 += this.dmethod_1856(class_3.prop_0);
                        num2 += this.dmethod_1856(class_3.prop_1);
                        num  += num2;
                    }
                }
                num++;
                class_2.prop_2 = num;
                return(num);
            }

            case Class_295.Array:
            {
                Class_289 class_4 = (Class_289)arg_0;
                int       num3    = 4;
                ulong     num4    = 0UL;
                using (IEnumerator <Class_287> enumerator2 = class_4.smethod_1960())
                {
                    while (enumerator2.MoveNext())
                    {
                        Class_287 arg_ = enumerator2.Current;
                        num3++;
                        num3 += this.cmethod_1854(Class_511.IntLength(num4));
                        num3 += this.dmethod_1856(arg_);
                        num4 += 1UL;
                    }
                }
                num3++;
                class_4.prop_2 = num3;
                return(class_4.prop_2);
            }

            case Class_295.Binary:
            {
                Class_292 class_5 = (Class_292)arg_0;
                byte[]    array   = (byte[])class_5.prop_0;
                class_5.prop_2 = 5 + array.Length;
                return(class_5.prop_2);
            }

            case Class_295.Undefined:
            case Class_295.Null:
                return(0);

            case Class_295.Oid:
                return(12);

            case Class_295.Boolean:
                return(1);

            case Class_295.Date:
                return(8);

            case Class_295.Regex:
            {
                Class_293 class_6 = (Class_293)arg_0;
                int       num5    = 0;
                num5          += this.dmethod_1856(class_6.prop_0);
                num5          += this.dmethod_1856(class_6.prop_1);
                class_6.prop_2 = num5;
                return(class_6.prop_2);
            }

            case Class_295.Integer:
                return(4);

            case Class_295.Long:
                return(8);
            }
            throw new ArgumentOutOfRangeException("t", "Unexpected token when writing BSON: {0}".FormatWith(CultureInfo.InvariantCulture, arg_0.prop_0));
        }