Esempio n. 1
0
        // Token: 0x06000C04 RID: 3076 RVA: 0x00043064 File Offset: 0x00041264
        public virtual object xmethod_2161(Class_285 arg_0, Type arg_1, object obje_0, Class_418 arg_2)
        {
            if (arg_0.prop_9 == Class_508.Null)
            {
                return(null);
            }
            object    obj    = null;
            string    text   = null;
            Class_424 class_ = null;

            Class_305.gmethod_2163(arg_0);
            while (arg_0.prop_9 == Class_508.PropertyName)
            {
                string text2 = arg_0.prop_10.ToString();
                if (string.Equals(text2, "Case", StringComparison.OrdinalIgnoreCase))
                {
                    Class_305.gmethod_2163(arg_0);
                    Class_489 <object, object> getUnionCases = Class_484.GetUnionCases;
                    object   target = null;
                    object[] array  = new object[2];
                    array[0] = arg_1;
                    IEnumerable enumerable = (IEnumerable)getUnionCases(target, array);
                    text = arg_0.prop_10.ToString();
                    foreach (object obj2 in enumerable)
                    {
                        if ((string)Class_484.GetUnionCaseInfoName(obj2) == text)
                        {
                            obj = obj2;
                            break;
                        }
                    }
                    if (obj == null)
                    {
                        throw Class_417.xmethod_3101(arg_0, "No union type found with the name '{0}'.".FormatWith(CultureInfo.InvariantCulture, text));
                    }
                }
                else
                {
                    if (!string.Equals(text2, "Fields", StringComparison.OrdinalIgnoreCase))
                    {
                        throw Class_417.xmethod_3101(arg_0, "Unexpected property '{0}' found when reading union.".FormatWith(CultureInfo.InvariantCulture, text2));
                    }
                    Class_305.gmethod_2163(arg_0);
                    if (arg_0.prop_9 != Class_508.StartArray)
                    {
                        throw Class_417.xmethod_3101(arg_0, "Union fields must been an array.");
                    }
                    class_ = (Class_424)Class_361.dmethod_2566(arg_0);
                }
                Class_305.gmethod_2163(arg_0);
            }
            if (obj == null)
            {
                throw Class_417.xmethod_3101(arg_0, "No '{0}' property with union name found.".FormatWith(CultureInfo.InvariantCulture, "Case"));
            }
            PropertyInfo[] array2 = (PropertyInfo[])Class_484.GetUnionCaseInfoFields(obj, new object[0]);
            object[]       array3 = new object[array2.Length];
            if (array2.Length > 0 && class_ == null)
            {
                throw Class_417.xmethod_3101(arg_0, "No '{0}' property with union fields found.".FormatWith(CultureInfo.InvariantCulture, "Fields"));
            }
            if (class_ != null)
            {
                if (array2.Length != class_.prop_9)
                {
                    throw Class_417.xmethod_3101(arg_0, "The number of field values does not match the number of properties definied by union '{0}'.".FormatWith(CultureInfo.InvariantCulture, text));
                }
                for (int i = 0; i < class_.prop_9; i++)
                {
                    Class_361    class_2      = class_.lmethod_3358(i);
                    PropertyInfo propertyInfo = array2[i];
                    array3[i] = class_2.vmethod_2565(propertyInfo.PropertyType, arg_2);
                }
            }
            Class_489 <object, object> makeUnion = Class_484.MakeUnion;
            object target2 = null;

            object[] array4 = new object[3];
            array4[0] = obj;
            array4[1] = array3;
            return(makeUnion(target2, array4));
        }