Exemplo n.º 1
0
    // Token: 0x060005BA RID: 1466 RVA: 0x00027A68 File Offset: 0x00025C68
    private static object smethod_11(object object_0, Type type_0, Type type_1)
    {
        Type type = (object_0 != null) ? object_0.GetType() : null;

        if (object_0 != null)
        {
            if (type_1.IsAssignableFrom(type))
            {
                return(object_0);
            }
            Func <object, object> func = Class23.class99_0.Get(new Struct9 <Type, Type>(type, type_1));
            if (func != null)
            {
                return(func(object_0));
            }
        }
        else if (Class90.smethod_10(type_1))
        {
            return(null);
        }
        string          string_          = "Could not cast or convert from {0} to {1}.";
        IFormatProvider invariantCulture = CultureInfo.InvariantCulture;
        string          object_;

        if (type_0 != null)
        {
            if ((object_ = type_0.ToString()) != null)
            {
                goto IL_5F;
            }
        }
        object_ = "{null}";
IL_5F:
        throw new ArgumentException(string_.smethod_1(invariantCulture, object_, type_1));
    }
Exemplo n.º 2
0
    // Token: 0x060005B9 RID: 1465 RVA: 0x00027A1C File Offset: 0x00025C1C
    public static object smethod_10(object object_0, object object_1, Type type_0)
    {
        if (type_0 == typeof(object))
        {
            return(object_0);
        }
        if (object_0 == null && Class90.smethod_10(type_0))
        {
            return(null);
        }
        object result;

        if (Class23.TryConvert(object_0, object_1, type_0, out result))
        {
            return(result);
        }
        return(Class23.smethod_11(object_0, Class90.smethod_3(object_0), type_0));
    }
Exemplo n.º 3
0
    // Token: 0x060005B8 RID: 1464 RVA: 0x00027754 File Offset: 0x00025954
    private static Class23.Enum5 smethod_9(object object_0, object object_1, Type type_0, out object object_2)
    {
        if (object_0 == null)
        {
            throw new ArgumentNullException("initialValue");
        }
        if (Class90.smethod_11(type_0))
        {
            type_0 = Nullable.GetUnderlyingType(type_0);
        }
        Type type = object_0.GetType();

        if (type_0 == type)
        {
            object_2 = object_0;
            return((Class23.Enum5) 0);
        }
        if (Class23.smethod_3(object_0.GetType()) && Class23.smethod_3(type_0))
        {
            if (type_0.smethod_8())
            {
                if (object_0 is string)
                {
                    object_2 = Enum.Parse(type_0, object_0.ToString(), true);
                    return((Class23.Enum5) 0);
                }
                if (Class23.smethod_13(object_0))
                {
                    object_2 = Enum.ToObject(type_0, object_0);
                    return((Class23.Enum5) 0);
                }
            }
            object_2 = Convert.ChangeType(object_0, type_0, object_1);
            return((Class23.Enum5) 0);
        }
        if (object_0 is DateTime)
        {
            DateTime dateTime = (DateTime)object_0;
            if (type_0 == typeof(DateTimeOffset))
            {
                object_2 = new DateTimeOffset(dateTime);
                return((Class23.Enum5) 0);
            }
        }
        byte[] b;
        if ((b = (object_0 as byte[])) != null && type_0 == typeof(Guid))
        {
            object_2 = new Guid(b);
            return((Class23.Enum5) 0);
        }
        if (object_0 is Guid)
        {
            Guid guid = (Guid)object_0;
            if (type_0 == typeof(byte[]))
            {
                object_2 = guid.ToByteArray();
                return((Class23.Enum5) 0);
            }
        }
        string text;

        if ((text = (object_0 as string)) != null)
        {
            if (type_0 == typeof(Guid))
            {
                object_2 = new Guid(text);
                return((Class23.Enum5) 0);
            }
            if (type_0 == typeof(Uri))
            {
                object_2 = new Uri(text, UriKind.RelativeOrAbsolute);
                return((Class23.Enum5) 0);
            }
            if (type_0 == typeof(TimeSpan))
            {
                object_2 = Class23.smethod_4(text);
                return((Class23.Enum5) 0);
            }
            if (type_0 == typeof(byte[]))
            {
                object_2 = Convert.FromBase64String(text);
                return((Class23.Enum5) 0);
            }
            if (type_0 == typeof(Version))
            {
                Version version;
                if (Version.TryParse(text, out version))
                {
                    object_2 = version;
                    return((Class23.Enum5) 0);
                }
                object_2 = null;
                return((Class23.Enum5) 3);
            }
            else if (typeof(Type).IsAssignableFrom(type_0))
            {
                object_2 = Type.GetType(text, true);
                return((Class23.Enum5) 0);
            }
        }
        if (type_0 == typeof(BigInteger))
        {
            object_2 = Class23.smethod_6(object_0);
            return((Class23.Enum5) 0);
        }
        if (object_0 is BigInteger)
        {
            BigInteger bigInteger_ = (BigInteger)object_0;
            object_2 = Class23.smethod_7(bigInteger_, type_0);
            return((Class23.Enum5) 0);
        }
        TypeConverter converter = TypeDescriptor.GetConverter(type);

        if (converter != null && converter.CanConvertTo(type_0))
        {
            object_2 = converter.ConvertTo(null, object_1, object_0, type_0);
            return((Class23.Enum5) 0);
        }
        TypeConverter converter2 = TypeDescriptor.GetConverter(type_0);

        if (converter2 != null && converter2.CanConvertFrom(type))
        {
            object_2 = converter2.ConvertFrom(null, object_1, object_0);
            return((Class23.Enum5) 0);
        }
        if (object_0 == DBNull.Value)
        {
            if (Class90.smethod_10(type_0))
            {
                object_2 = Class23.smethod_11(null, type, type_0);
                return((Class23.Enum5) 0);
            }
            object_2 = null;
            return((Class23.Enum5) 1);
        }
        else
        {
            if (!type_0.smethod_3() && !type_0.smethod_5() && !type_0.smethod_11())
            {
                object_2 = null;
                return((Class23.Enum5) 3);
            }
            object_2 = null;
            return((Class23.Enum5) 2);
        }
    }