コード例 #1
0
        int ReadMembers(int index, ClassDataContract classContract, BitFlagsGenerator expectedElements, ref int memberIndex)
        {
            int memberCount = (classContract.BaseContract == null) ? 0 : ReadMembers(index, classContract.BaseContract, expectedElements,
                                                                                     ref memberIndex);

            if (memberCount <= index && index < memberCount + classContract.Members.Count)
            {
                DataMember dataMember = classContract.Members [index - memberCount];
                Type       memberType = dataMember.MemberType;

                memberIndex = memberCount;
                if (!expectedElements.Load(index))
                {
                    XmlObjectSerializerReadContextComplexJson.ThrowDuplicateMemberException(objectLocal, memberNames, memberIndex);
                }

                if (dataMember.IsGetOnlyCollection)
                {
                    var value = CodeInterpreter.GetMember(dataMember.MemberInfo, objectLocal);
                    context.StoreCollectionMemberInfo(value);
                    ReadValue(memberType, dataMember.Name);
                }
                else
                {
                    var value = ReadValue(memberType, dataMember.Name);
                    CodeInterpreter.SetMember(dataMember.MemberInfo, objectLocal, value);
                }
                memberIndex = index;
                ResetExpectedElements(expectedElements, index);
            }
            return(memberCount + classContract.Members.Count);
        }