예제 #1
0
        // Token: 0x0600506D RID: 20589 RVA: 0x0011A9FC File Offset: 0x00118BFC
        private static MemberInfo[] InternalGetSerializableMembers(RuntimeType type)
        {
            if (type.IsInterface)
            {
                return(new MemberInfo[0]);
            }
            if (!FormatterServices.CheckSerializable(type))
            {
                throw new SerializationException(Environment.GetResourceString("Serialization_NonSerType", new object[]
                {
                    type.FullName,
                    type.Module.Assembly.FullName
                }));
            }
            MemberInfo[] array       = FormatterServices.GetSerializableMembers(type);
            RuntimeType  runtimeType = (RuntimeType)type.BaseType;

            if (runtimeType != null && runtimeType != (RuntimeType)typeof(object))
            {
                RuntimeType[] array2      = null;
                int           num         = 0;
                bool          parentTypes = FormatterServices.GetParentTypes(runtimeType, out array2, out num);
                if (num > 0)
                {
                    List <SerializationFieldInfo> list = new List <SerializationFieldInfo>();
                    for (int i = 0; i < num; i++)
                    {
                        runtimeType = array2[i];
                        if (!FormatterServices.CheckSerializable(runtimeType))
                        {
                            throw new SerializationException(Environment.GetResourceString("Serialization_NonSerType", new object[]
                            {
                                runtimeType.FullName,
                                runtimeType.Module.Assembly.FullName
                            }));
                        }
                        FieldInfo[] fields     = runtimeType.GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
                        string      namePrefix = parentTypes ? runtimeType.Name : runtimeType.FullName;
                        foreach (FieldInfo fieldInfo in fields)
                        {
                            if (!fieldInfo.IsNotSerialized)
                            {
                                list.Add(new SerializationFieldInfo((RuntimeFieldInfo)fieldInfo, namePrefix));
                            }
                        }
                    }
                    if (list != null && list.Count > 0)
                    {
                        MemberInfo[] array4 = new MemberInfo[list.Count + array.Length];
                        Array.Copy(array, array4, array.Length);
                        ((ICollection)list).CopyTo(array4, array.Length);
                        array = array4;
                    }
                }
            }
            return(array);
        }
예제 #2
0
        private static MemberInfo[] InternalGetSerializableMembers(RuntimeType type)
        {
            if (type.IsInterface)
            {
                return(new MemberInfo[0]);
            }
            if (!FormatterServices.CheckSerializable(type))
            {
                throw new SerializationException(Environment.GetResourceString("Serialization_NonSerType", (object)type.FullName, (object)type.Module.Assembly.FullName));
            }
            MemberInfo[] memberInfoArray1 = FormatterServices.GetSerializableMembers(type);
            RuntimeType  parentType       = (RuntimeType)type.BaseType;

            if (parentType != (RuntimeType)null && parentType != (RuntimeType)typeof(object))
            {
                RuntimeType[] parentTypes1    = (RuntimeType[])null;
                int           parentTypeCount = 0;
                bool          parentTypes2    = FormatterServices.GetParentTypes(parentType, out parentTypes1, out parentTypeCount);
                if (parentTypeCount > 0)
                {
                    List <SerializationFieldInfo> serializationFieldInfoList = new List <SerializationFieldInfo>();
                    for (int index = 0; index < parentTypeCount; ++index)
                    {
                        RuntimeType type1 = parentTypes1[index];
                        if (!FormatterServices.CheckSerializable(type1))
                        {
                            throw new SerializationException(Environment.GetResourceString("Serialization_NonSerType", (object)type1.FullName, (object)type1.Module.Assembly.FullName));
                        }
                        FieldInfo[] fields     = type1.GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
                        string      namePrefix = parentTypes2 ? type1.Name : type1.FullName;
                        foreach (FieldInfo fieldInfo in fields)
                        {
                            if (!fieldInfo.IsNotSerialized)
                            {
                                serializationFieldInfoList.Add(new SerializationFieldInfo((RuntimeFieldInfo)fieldInfo, namePrefix));
                            }
                        }
                    }
                    if (serializationFieldInfoList != null && serializationFieldInfoList.Count > 0)
                    {
                        MemberInfo[] memberInfoArray2 = new MemberInfo[serializationFieldInfoList.Count + memberInfoArray1.Length];
                        Array.Copy((Array)memberInfoArray1, (Array)memberInfoArray2, memberInfoArray1.Length);
                        ((ICollection)serializationFieldInfoList).CopyTo((Array)memberInfoArray2, memberInfoArray1.Length);
                        memberInfoArray1 = memberInfoArray2;
                    }
                }
            }
            return(memberInfoArray1);
        }