Ejemplo n.º 1
0
        // Token: 0x06000C31 RID: 3121 RVA: 0x00043F1C File Offset: 0x0004211C
        public virtual object lmethod_2198(Class_285 arg_0, Type arg_1, object obje_0, Class_418 arg_2)
        {
            bool flag = Class_514.IsNullableType(arg_1);
            Type type = flag ? Nullable.GetUnderlyingType(arg_1) : arg_1;

            if (arg_0.prop_9 != Class_508.Null)
            {
                try
                {
                    if (arg_0.prop_9 == Class_508.String)
                    {
                        string enumText = arg_0.prop_10.ToString();
                        return(Class_505.ParseEnumName(enumText, flag, type));
                    }
                    if (arg_0.prop_9 == Class_508.Integer)
                    {
                        if (!this.prop_1)
                        {
                            throw Class_417.xmethod_3101(arg_0, "Integer value {0} is not allowed.".FormatWith(CultureInfo.InvariantCulture, arg_0.prop_10));
                        }
                        return(Class_499.ConvertOrCast(arg_0.prop_10, CultureInfo.InvariantCulture, type));
                    }
                }
                catch (Exception arg_3)
                {
                    throw Class_417.tmethod_3102(arg_0, "Error converting value {0} to type '{1}'.".FormatWith(CultureInfo.InvariantCulture, Class_513.FormatValueForPrint(arg_0.prop_10), arg_1), arg_3);
                }
                throw Class_417.xmethod_3101(arg_0, "Unexpected token {0} when parsing enum.".FormatWith(CultureInfo.InvariantCulture, arg_0.prop_9));
            }
            if (!Class_514.IsNullableType(arg_1))
            {
                throw Class_417.xmethod_3101(arg_0, "Cannot convert null value to {0}.".FormatWith(CultureInfo.InvariantCulture, arg_1));
            }
            return(null);
        }
Ejemplo n.º 2
0
        // Token: 0x060011A5 RID: 4517 RVA: 0x00057214 File Offset: 0x00055414
        internal static U Convert <T, U>(this T token) where T : Class_361
        {
            if (token == null)
            {
                return(default(U));
            }
            if (token is U && typeof(U) != typeof(IComparable) && typeof(U) != typeof(IFormattable))
            {
                return((U)((object)token));
            }
            Class_362 class_ = token as Class_362;

            if (class_ == null)
            {
                throw new InvalidCastException("Cannot cast {0} to {1}.".FormatWith(CultureInfo.InvariantCulture, token.GetType(), typeof(T)));
            }
            if (class_.prop_2 is U)
            {
                return((U)((object)class_.prop_2));
            }
            Type type = typeof(U);

            if (Class_514.IsNullableType(type))
            {
                if (class_.prop_2 == null)
                {
                    return(default(U));
                }
                type = Nullable.GetUnderlyingType(type);
            }
            return((U)((object)System.Convert.ChangeType(class_.prop_2, type, CultureInfo.InvariantCulture)));
        }
Ejemplo n.º 3
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.º 4
0
        // Token: 0x06000F7F RID: 3967 RVA: 0x0004FCF4 File Offset: 0x0004DEF4
        public virtual object kmethod_2807(Class_285 arg_0, Type arg_1, object obje_0, Class_418 arg_2)
        {
            bool flag = Class_514.IsNullableType(arg_1);
            Type left = flag ? Nullable.GetUnderlyingType(arg_1) : arg_1;

            if (arg_0.prop_9 == Class_508.Null)
            {
                if (!Class_514.IsNullableType(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.Date)
            {
                if (!(left == typeof(DateTimeOffset)))
                {
                    return(arg_0.prop_10);
                }
                if (!(arg_0.prop_10 is DateTimeOffset))
                {
                    return(new DateTimeOffset((DateTime)arg_0.prop_10));
                }
                return(arg_0.prop_10);
            }
            else
            {
                if (arg_0.prop_9 != Class_508.String)
                {
                    throw Class_417.xmethod_3101(arg_0, "Unexpected token parsing date. Expected String, got {0}.".FormatWith(CultureInfo.InvariantCulture, arg_0.prop_9));
                }
                string text = arg_0.prop_10.ToString();
                if (string.IsNullOrEmpty(text) && flag)
                {
                    return(null);
                }
                if (left == typeof(DateTimeOffset))
                {
                    if (!string.IsNullOrEmpty(this.field_2))
                    {
                        return(DateTimeOffset.ParseExact(text, this.field_2, this.prop_2, this.field_1));
                    }
                    return(DateTimeOffset.Parse(text, this.prop_2, this.field_1));
                }
                else
                {
                    if (!string.IsNullOrEmpty(this.field_2))
                    {
                        return(DateTime.ParseExact(text, this.field_2, this.prop_2, this.field_1));
                    }
                    return(DateTime.Parse(text, this.prop_2, this.field_1));
                }
            }
        }
Ejemplo n.º 5
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.º 6
0
        // Token: 0x06000C19 RID: 3097 RVA: 0x000438D0 File Offset: 0x00041AD0
        public virtual object pmethod_2179(Class_285 arg_0, Type arg_1, object obje_0, Class_418 arg_2)
        {
            bool      flag   = Class_514.IsNullableType(arg_1);
            Type      type   = flag ? Nullable.GetUnderlyingType(arg_1) : arg_1;
            Class_491 class_ = Class_308.field_2.Get(type);

            if (arg_0.prop_9 != Class_508.Null)
            {
                object obj  = null;
                object obj2 = null;
                Class_308.xmethod_2181(arg_0);
                while (arg_0.prop_9 == Class_508.PropertyName)
                {
                    string a = arg_0.prop_10.ToString();
                    if (string.Equals(a, "Key", StringComparison.OrdinalIgnoreCase))
                    {
                        Class_308.xmethod_2181(arg_0);
                        obj = arg_2.smethod_3170(arg_0, class_.cmethod_4064("Key"));
                    }
                    else if (string.Equals(a, "Value", StringComparison.OrdinalIgnoreCase))
                    {
                        Class_308.xmethod_2181(arg_0);
                        obj2 = arg_2.smethod_3170(arg_0, class_.cmethod_4064("Value"));
                    }
                    else
                    {
                        arg_0.smethod_1900();
                    }
                    Class_308.xmethod_2181(arg_0);
                }
                return(class_.prop_0(new object[]
                {
                    obj,
                    obj2
                }));
            }
            if (!flag)
            {
                throw Class_417.xmethod_3101(arg_0, "Cannot convert null value to KeyValuePair.");
            }
            return(null);
        }
Ejemplo n.º 7
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.º 8
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.º 9
0
        // Token: 0x06000C32 RID: 3122 RVA: 0x00044044 File Offset: 0x00042244
        public virtual bool pmethod_2199(Type arg_0)
        {
            Type type = Class_514.IsNullableType(arg_0) ? Nullable.GetUnderlyingType(arg_0) : arg_0;

            return(type.IsEnum);
        }
Ejemplo n.º 10
0
        // Token: 0x06000C1A RID: 3098 RVA: 0x000439DC File Offset: 0x00041BDC
        public virtual bool smethod_2180(Type arg_0)
        {
            Type type = Class_514.IsNullableType(arg_0) ? Nullable.GetUnderlyingType(arg_0) : arg_0;

            return(type.IsValueType && type.IsGenericType && type.GetGenericTypeDefinition() == typeof(KeyValuePair <, >));
        }