Ejemplo n.º 1
0
        // Token: 0x060014E3 RID: 5347 RVA: 0x0006101C File Offset: 0x0005F21C
        private Class_463 cmethod_3824(Type arg_0, Class_364 arg_1)
        {
            Class_463 class_ = Class_463.None;

            if (arg_1 != Class_364.Always && Class_514.IsNullable(arg_0))
            {
                class_ = Class_463.Null;
                if (Class_514.IsNullableType(arg_0))
                {
                    arg_0 = Nullable.GetUnderlyingType(arg_0);
                }
            }
            Class_496 typeCode = Class_499.GetTypeCode(arg_0);

            switch (typeCode)
            {
            case Class_496.Empty:
            case Class_496.Object:
                return(class_ | Class_463.String);

            case Class_496.Char:
                return(class_ | Class_463.String);

            case Class_496.Boolean:
                return(class_ | Class_463.Boolean);

            case Class_496.SByte:
            case Class_496.Int16:
            case Class_496.UInt16:
            case Class_496.Int32:
            case Class_496.Byte:
            case Class_496.UInt32:
            case Class_496.Int64:
            case Class_496.UInt64:
            case Class_496.BigInteger:
                return(class_ | Class_463.Integer);

            case Class_496.Single:
            case Class_496.Double:
            case Class_496.Decimal:
                return(class_ | Class_463.Float);

            case Class_496.DateTime:
            case Class_496.DateTimeOffset:
                return(class_ | Class_463.String);

            case Class_496.Guid:
            case Class_496.TimeSpan:
            case Class_496.Uri:
            case Class_496.String:
            case Class_496.Bytes:
                return(class_ | Class_463.String);

            case Class_496.DBNull:
                return(class_ | Class_463.Null);
            }
            throw new Class_318("Unexpected type code '{0}' for type '{1}'.".FormatWith(CultureInfo.InvariantCulture, typeCode, arg_0));
        }
Ejemplo n.º 2
0
            // Token: 0x06000E99 RID: 3737 RVA: 0x0004D1D8 File Offset: 0x0004B3D8
            public virtual bool nmethod_0(Class_362 arg_0, ConvertBinder arg_1, out object arg_2)
            {
                if (arg_1.Type == typeof(Class_362))
                {
                    arg_2 = arg_0;
                    return(true);
                }
                object obj = arg_0.prop_2;

                if (obj == null)
                {
                    arg_2 = null;
                    return(Class_514.IsNullable(arg_1.Type));
                }
                arg_2 = Class_499.Convert(obj, CultureInfo.InvariantCulture, arg_1.Type);
                return(true);
            }
Ejemplo n.º 3
0
        // Token: 0x06000BEB RID: 3051 RVA: 0x000426A0 File Offset: 0x000408A0
        public virtual object xmethod_2141(Class_285 arg_0, Type arg_1, object obje_0, Class_418 arg_2)
        {
            Type type = Class_514.IsNullableType(arg_1) ? Nullable.GetUnderlyingType(arg_1) : arg_1;

            if (arg_0.prop_9 == Class_508.Null)
            {
                if (!Class_514.IsNullable(arg_1))
                {
                    throw Class_417.xmethod_3101(arg_0, "Cannot convert null value to {0}.".FormatWith(CultureInfo.InvariantCulture, arg_1));
                }
                return(null);
            }
            else
            {
                byte[] array;
                if (arg_0.prop_9 == Class_508.StartArray)
                {
                    array = this.tmethod_2142(arg_0);
                }
                else
                {
                    if (arg_0.prop_9 != Class_508.String)
                    {
                        throw Class_417.xmethod_3101(arg_0, "Unexpected token parsing binary. Expected String or StartArray, got {0}.".FormatWith(CultureInfo.InvariantCulture, arg_0.prop_9));
                    }
                    string s = arg_0.prop_10.ToString();
                    array = Convert.FromBase64String(s);
                }
                if (type.AssignableToTypeName("System.Data.Linq.Binary"))
                {
                    this.smethod_2140(type);
                    return(this.field_2.prop_0(new object[]
                    {
                        array
                    }));
                }
                if (type == typeof(SqlBinary))
                {
                    return(new SqlBinary(array));
                }
                throw Class_417.xmethod_3101(arg_0, "Unexpected object type when writing binary: {0}".FormatWith(CultureInfo.InvariantCulture, arg_1));
            }
        }
Ejemplo n.º 4
0
 // Token: 0x06000D28 RID: 3368 RVA: 0x00047C64 File Offset: 0x00045E64
 internal Class_349(Type arg_0)
 {
     Class_517.ArgumentNotNull(arg_0, "underlyingType");
     this.prop_0  = arg_0;
     this.field_0 = Class_514.IsNullable(arg_0);
     this.field_3 = ((this.field_0 && Class_514.IsNullableType(arg_0)) ? Nullable.GetUnderlyingType(arg_0) : arg_0);
     this.prop_1  = this.field_3;
     this.field_1 = Class_499.IsConvertible(this.field_3);
     this.field_2 = this.field_3.IsEnum;
     if (this.field_3 == typeof(byte[]))
     {
         this.field_4 = Class_408.ReadAsBytes;
         return;
     }
     if (this.field_3 == typeof(int))
     {
         this.field_4 = Class_408.ReadAsInt32;
         return;
     }
     if (this.field_3 == typeof(decimal))
     {
         this.field_4 = Class_408.ReadAsDecimal;
         return;
     }
     if (this.field_3 == typeof(string))
     {
         this.field_4 = Class_408.ReadAsString;
         return;
     }
     if (this.field_3 == typeof(DateTime))
     {
         this.field_4 = Class_408.ReadAsDateTime;
         return;
     }
     if (this.field_3 == typeof(DateTimeOffset))
     {
         this.field_4 = Class_408.ReadAsDateTimeOffset;
         return;
     }
     this.field_4 = Class_408.Read;
 }
Ejemplo n.º 5
0
        // Token: 0x06000F82 RID: 3970 RVA: 0x0004FF28 File Offset: 0x0004E128
        public virtual object pmethod_2809(Class_285 arg_0, Type arg_1, object obje_0, Class_418 arg_2)
        {
            Type left = Class_514.IsNullableType(arg_1) ? Nullable.GetUnderlyingType(arg_1) : arg_1;

            if (arg_0.prop_9 == Class_508.Null)
            {
                if (!Class_514.IsNullable(arg_1))
                {
                    throw Class_417.xmethod_3101(arg_0, "Cannot convert null value to {0}.".FormatWith(CultureInfo.InvariantCulture, arg_1));
                }
                return(null);
            }
            else
            {
                if (arg_0.prop_9 != Class_508.StartConstructor || !string.Equals(arg_0.prop_10.ToString(), "Date", StringComparison.Ordinal))
                {
                    throw Class_417.xmethod_3101(arg_0, "Unexpected token or value when parsing date. Token: {0}, Value: {1}".FormatWith(CultureInfo.InvariantCulture, arg_0.prop_9, arg_0.prop_10));
                }
                arg_0.vmethod_1885();
                if (arg_0.prop_9 != Class_508.Integer)
                {
                    throw Class_417.xmethod_3101(arg_0, "Unexpected token parsing date. Expected Integer, got {0}.".FormatWith(CultureInfo.InvariantCulture, arg_0.prop_9));
                }
                long     javaScriptTicks = (long)arg_0.prop_10;
                DateTime dateTime        = Class_502.ConvertJavaScriptTicksToDateTime(javaScriptTicks);
                arg_0.vmethod_1885();
                if (arg_0.prop_9 != Class_508.EndConstructor)
                {
                    throw Class_417.xmethod_3101(arg_0, "Unexpected token parsing date. Expected EndConstructor, got {0}.".FormatWith(CultureInfo.InvariantCulture, arg_0.prop_9));
                }
                if (left == typeof(DateTimeOffset))
                {
                    return(new DateTimeOffset(dateTime));
                }
                return(dateTime);
            }
        }
Ejemplo n.º 6
0
        // Token: 0x060014DD RID: 5341 RVA: 0x000608BC File Offset: 0x0005EABC
        private Class_459 lmethod_3818(Type arg_0, Class_364 arg_1, bool bool_0)
        {
            Class_462.NClass_1 nclass_ = new Class_462.NClass_1();
            nclass_.field_7 = arg_0;
            Class_517.ArgumentNotNull(nclass_.field_7, "type");
            string text  = this.kmethod_3817(nclass_.field_7, false);
            string text2 = this.kmethod_3817(nclass_.field_7, true);

            if (!string.IsNullOrEmpty(text))
            {
                Class_459 class_ = this.field_1.xmethod_3531(text);
                if (class_ != null)
                {
                    if (arg_1 != Class_364.Always && !Class_462.gmethod_3823(class_.prop_7, Class_463.Null))
                    {
                        class_.prop_7 |= Class_463.Null;
                    }
                    if (bool_0 && class_.prop_2 != true)
                    {
                        class_.prop_2 = new bool?(true);
                    }
                    return(class_);
                }
            }
            if (this.field_2.Any(new Func <Class_462.NClass_0, bool>(nclass_.nmethod_6)))
            {
                throw new Class_318("Unresolved circular reference for type '{0}'. Explicitly define an Id for the type using a JsonObject/JsonArray attribute or automatically generate a type Id using the UndefinedSchemaIdHandling property.".FormatWith(CultureInfo.InvariantCulture, nclass_.field_7));
            }
            Class_349 class_2 = this.prop_1.tmethod_3542(nclass_.field_7);
            Class_299 class_3;

            if ((class_3 = class_2.prop_3) != null || (class_3 = class_2.prop_4) != null)
            {
                Class_459 class_4 = class_3.vmethod_2135();
                if (class_4 != null)
                {
                    return(class_4);
                }
            }
            this.pmethod_3809(new Class_462.NClass_0(nclass_.field_7, new Class_459()));
            if (text2 != null)
            {
                this.prop_2.prop_0 = text2;
            }
            if (bool_0)
            {
                this.prop_2.prop_2 = new bool?(true);
            }
            this.prop_2.prop_1 = this.vmethod_3815(nclass_.field_7);
            this.prop_2.prop_6 = this.dmethod_3816(nclass_.field_7);
            if (class_3 != null)
            {
                this.prop_2.prop_7 = new Class_463?(Class_463.Any);
            }
            else
            {
                switch (class_2.field_5)
                {
                case Class_448.Object:
                    this.prop_2.prop_7 = new Class_463?(this.pmethod_3819(Class_463.Object, arg_1));
                    this.prop_2.prop_0 = this.kmethod_3817(nclass_.field_7, false);
                    this.xmethod_3821(nclass_.field_7, (Class_464)class_2);
                    goto IL_519;

                case Class_448.Array:
                    {
                        this.prop_2.prop_7 = new Class_463?(this.pmethod_3819(Class_463.Array, arg_1));
                        this.prop_2.prop_0 = this.kmethod_3817(nclass_.field_7, false);
                        Class_376 cachedAttribute    = Class_470.GetCachedAttribute <Class_376>(nclass_.field_7);
                        bool      flag               = cachedAttribute == null || cachedAttribute.AllowNullItems;
                        Type      collectionItemType = Class_514.GetCollectionItemType(nclass_.field_7);
                        if (collectionItemType != null)
                        {
                            this.prop_2.prop_18 = new List <Class_459>();
                            this.prop_2.prop_18.Add(this.lmethod_3818(collectionItemType, (!flag) ? Class_364.Always : Class_364.Default, false));
                            goto IL_519;
                        }
                        goto IL_519;
                    }

                case Class_448.Primitive:
                {
                    this.prop_2.prop_7 = new Class_463?(this.cmethod_3824(nclass_.field_7, arg_1));
                    if (!(this.prop_2.prop_7 == Class_463.Integer) || !nclass_.field_7.IsEnum || nclass_.field_7.IsDefined(typeof(FlagsAttribute), true))
                    {
                        goto IL_519;
                    }
                    this.prop_2.prop_28 = new List <Class_361>();
                    IList <Class_506 <long> > namesAndValues = Class_505.GetNamesAndValues <long>(nclass_.field_7);
                    using (IEnumerator <Class_506 <long> > enumerator = namesAndValues.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Class_506 <long> class_5 = enumerator.Current;
                            Class_361        item    = Class_361.smethod_2560(class_5.Value);
                            this.prop_2.prop_28.Add(item);
                        }
                        goto IL_519;
                    }
                    break;
                }

                case Class_448.String:
                    break;

                case Class_448.Dictionary:
                {
                    this.prop_2.prop_7 = new Class_463?(this.pmethod_3819(Class_463.Object, arg_1));
                    Type type;
                    Type arg_2;
                    Class_514.GetDictionaryKeyValueTypes(nclass_.field_7, out type, out arg_2);
                    if (!(type != null))
                    {
                        goto IL_519;
                    }
                    Class_349 class_6 = this.prop_1.tmethod_3542(type);
                    if (class_6.field_5 == Class_448.Primitive)
                    {
                        this.prop_2.prop_24 = this.lmethod_3818(arg_2, Class_364.Default, false);
                        goto IL_519;
                    }
                    goto IL_519;
                }

                case Class_448.Dynamic:
                case Class_448.Linq:
                    this.prop_2.prop_7 = new Class_463?(Class_463.Any);
                    goto IL_519;

                case Class_448.Serializable:
                    this.prop_2.prop_7 = new Class_463?(this.pmethod_3819(Class_463.Object, arg_1));
                    this.prop_2.prop_0 = this.kmethod_3817(nclass_.field_7, false);
                    this.tmethod_3822(nclass_.field_7, (Class_367)class_2);
                    goto IL_519;

                default:
                    throw new Class_318("Unexpected contract type: {0}".FormatWith(CultureInfo.InvariantCulture, class_2));
                }
                Class_463 value = (!Class_514.IsNullable(class_2.prop_0)) ? Class_463.String : this.pmethod_3819(Class_463.String, arg_1);
                this.prop_2.prop_7 = new Class_463?(value);
            }
            IL_519:
            return(this.smethod_3810().nprop_1);
        }