System.Runtime.Serialization.Formatters.Binary.ObjectMapInfo.isCompatible C# (CSharp) Method

isCompatible() private method

private isCompatible ( int numMembers, String memberNames, Type memberTypes ) : bool
numMembers int
memberNames String
memberTypes System.Type
return bool
        internal bool isCompatible(int numMembers, String[] memberNames, Type[] memberTypes)
        {
            bool result = true;
            if (this.numMembers == numMembers)
            {
                for (int i=0; i<numMembers; i++)
                {
                    if (!(this.memberNames[i].Equals(memberNames[i])))
                    {
                        result = false;
                        break;
                    }
                    if ((memberTypes != null) && (this.memberTypes[i] != memberTypes[i]))
                    {
                        result = false;
                        break;
                    }
                }
            }
            else
                result = false;
            return result;
        }

Usage Example

示例#1
0
        //internal BinaryCrossAppDomainMap crossAppDomainMap;

        internal void WriteObject(NameInfo nameInfo, NameInfo typeNameInfo, int numMembers, String[] memberNames, Type[] memberTypes, WriteObjectInfo[] memberObjectInfos)
        {
            InternalWriteItemNull();
            int assemId;

            nameInfo.Dump("WriteObject nameInfo");
            typeNameInfo.Dump("WriteObject typeNameInfo");

            int objectId = (int)nameInfo.NIobjectId;

            //if (objectId < 0)
            //	objectId = --m_nestedObjectCount;

            if (objectId > 0)
            {
                BCLDebug.Trace("BINARY", "-----Top Level Object-----");
            }

            String objectName = null;

            if (objectId < 0)
            {
                // Nested Object
                objectName = typeNameInfo.NIname;
            }
            else
            {
                // Non-Nested
                objectName = nameInfo.NIname;
            }
            SerTrace.Log(this, "WriteObject objectName ", objectName);

            if (objectMapTable == null)
            {
                objectMapTable = new Hashtable();
            }

            ObjectMapInfo objectMapInfo = (ObjectMapInfo)objectMapTable[objectName];

            if (objectMapInfo != null && objectMapInfo.isCompatible(numMembers, memberNames, memberTypes))
            {
                // Object
                if (binaryObject == null)
                {
                    binaryObject = new BinaryObject();
                }
                binaryObject.Set(objectId, objectMapInfo.objectId);
                binaryObject.Dump();
                binaryObject.Write(this);
            }
            else if (!typeNameInfo.NItransmitTypeOnObject)
            {
                // ObjectWithMap
                if (binaryObjectWithMap == null)
                {
                    binaryObjectWithMap = new BinaryObjectWithMap();
                }

                // BCL types are not placed into table
                assemId = (int)typeNameInfo.NIassemId;
                binaryObjectWithMap.Set(objectId, objectName, numMembers, memberNames, assemId);

                binaryObjectWithMap.Dump();
                binaryObjectWithMap.Write(this);
                if (objectMapInfo == null)
                {
                    objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes));
                }
            }
            else
            {
                // ObjectWithMapTyped
                BinaryTypeEnum[] binaryTypeEnumA  = new BinaryTypeEnum[numMembers];
                Object[]         typeInformationA = new Object[numMembers];
                int[]            assemIdA         = new int[numMembers];
                for (int i = 0; i < numMembers; i++)
                {
                    Object typeInformation = null;

                    binaryTypeEnumA[i]  = BinaryConverter.GetBinaryTypeInfo(memberTypes[i], memberObjectInfos[i], null, objectWriter, out typeInformation, out assemId);
                    typeInformationA[i] = typeInformation;
                    assemIdA[i]         = assemId;
                    SerTrace.Log(this, "WriteObject ObjectWithMapTyped memberNames "
                                 , memberNames[i], ", memberType ", memberTypes[i], " binaryTypeEnum ", ((Enum)binaryTypeEnumA[i]).ToString()
                                 , ", typeInformation ", typeInformationA[i], " assemId ", assemIdA[i]);
                }

                if (binaryObjectWithMapTyped == null)
                {
                    binaryObjectWithMapTyped = new BinaryObjectWithMapTyped();
                }

                // BCL types are not placed in table
                assemId = (int)typeNameInfo.NIassemId;
                binaryObjectWithMapTyped.Set(objectId, objectName, numMembers, memberNames, binaryTypeEnumA, typeInformationA, assemIdA, assemId);

                binaryObjectWithMapTyped.Dump();
                binaryObjectWithMapTyped.Write(this);
                if (objectMapInfo == null)
                {
                    objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes));
                }
            }
        }
All Usage Examples Of System.Runtime.Serialization.Formatters.Binary.ObjectMapInfo::isCompatible