示例#1
0
        // Token: 0x06000369 RID: 873 RVA: 0x000096B4 File Offset: 0x000086B4
        private int ReadType(Context context, out ComplexValue complexValue)
        {
            complexValue = null;
            TypeDescription type      = context.Type;
            int             index     = context.Index;
            byte            b         = 0;
            ArrayList       arrayList = new ArrayList();

            for (int i = 0; i < type.Field.Length; i++)
            {
                FieldType    fieldType     = type.Field[i];
                ComplexValue complexValue2 = new ComplexValue();
                complexValue2.Name  = ((fieldType.Name != null && fieldType.Name.Length != 0) ? fieldType.Name : ("[" + i.ToString() + "]"));
                complexValue2.Type  = null;
                complexValue2.Value = null;
                if (b != 0 && fieldType.GetType() != typeof(BitString))
                {
                    context.Index++;
                    b = 0;
                }
                int num;
                if (base.IsArrayField(fieldType))
                {
                    num = this.ReadArrayField(context, fieldType, i, arrayList, out complexValue2.Value);
                }
                else if (fieldType.GetType() == typeof(TypeReference))
                {
                    object obj = null;
                    num = this.ReadField(context, (TypeReference)fieldType, out obj);
                    complexValue2.Name  = fieldType.Name;
                    complexValue2.Type  = ((ComplexValue)obj).Type;
                    complexValue2.Value = ((ComplexValue)obj).Value;
                }
                else
                {
                    num = this.ReadField(context, fieldType, i, arrayList, out complexValue2.Value, ref b);
                }
                if (num == 0 && b == 0)
                {
                    throw new InvalidDataInBufferException(string.Concat(new string[]
                    {
                        "Could not read field '",
                        fieldType.Name,
                        "' in type '",
                        type.TypeID,
                        "'."
                    }));
                }
                context.Index += num;
                if (complexValue2.Type == null)
                {
                    complexValue2.Type = Convert.ToString(complexValue2.Value.GetType());
                }
                arrayList.Add(complexValue2);
            }
            if (b != 0)
            {
                context.Index++;
            }
            complexValue       = new ComplexValue();
            complexValue.Name  = type.TypeID;
            complexValue.Type  = type.TypeID;
            complexValue.Value = (ComplexValue[])arrayList.ToArray(typeof(ComplexValue));
            return(context.Index - index);
        }