예제 #1
0
        // Writes a given object to the stream.
        private void Write(WriteObjectInfo objectInfo,
                           NameInfo memberNameInfo,
                           NameInfo typeNameInfo,
                           string[] memberNames,
                           Type[] memberTypes,
                           object[] memberData,
                           WriteObjectInfo[] memberObjectInfos)
        {
            int      numItems    = memberNames.Length;
            NameInfo topNameInfo = null;

            if (memberNameInfo != null)
            {
                memberNameInfo._objectId = objectInfo._objectId;
                _serWriter.WriteObject(memberNameInfo, typeNameInfo, numItems, memberNames, memberTypes, memberObjectInfos);
            }
            else if ((objectInfo._objectId == _topId) && (_topName != null))
            {
                topNameInfo           = MemberToNameInfo(_topName);
                topNameInfo._objectId = objectInfo._objectId;
                _serWriter.WriteObject(topNameInfo, typeNameInfo, numItems, memberNames, memberTypes, memberObjectInfos);
            }
            else
            {
                if (!ReferenceEquals(objectInfo._objectType, Converter.s_typeofString))
                {
                    typeNameInfo._objectId = objectInfo._objectId;
                    _serWriter.WriteObject(typeNameInfo, null, numItems, memberNames, memberTypes, memberObjectInfos);
                }
            }

            if (memberNameInfo._isParentTypeOnObject)
            {
                memberNameInfo._transmitTypeOnObject = true;
                memberNameInfo._isParentTypeOnObject = false;
            }
            else
            {
                memberNameInfo._transmitTypeOnObject = false;
            }

            // Write members
            for (int i = 0; i < numItems; i++)
            {
                WriteMemberSetup(objectInfo, memberNameInfo, typeNameInfo, memberNames[i], memberTypes[i], memberData[i], memberObjectInfos[i]);
            }

            if (memberNameInfo != null)
            {
                memberNameInfo._objectId = objectInfo._objectId;
                _serWriter.WriteObjectEnd(memberNameInfo, typeNameInfo);
            }
            else if ((objectInfo._objectId == _topId) && (_topName != null))
            {
                _serWriter.WriteObjectEnd(topNameInfo, typeNameInfo);
                PutNameInfo(topNameInfo);
            }
            else if (!ReferenceEquals(objectInfo._objectType, Converter.s_typeofString))
            {
                _serWriter.WriteObjectEnd(typeNameInfo, typeNameInfo);
            }
        }