[System.Security.SecurityCritical]  // auto-generated
        internal void WriteSingleArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound, Array array)
        {
            InternalWriteItemNull();
#if _DEBUG
            arrayNameInfo.Dump("WriteSingleArray arrayNameInfo");
            arrayElemTypeNameInfo.Dump("WriteSingleArray arrayElemTypeNameInfo");
#endif
            BinaryArrayTypeEnum binaryArrayTypeEnum;
            Int32[]             lengthA = new Int32[1];
            lengthA[0] = length;
            Int32[] lowerBoundA     = null;
            Object  typeInformation = null;

            if (lowerBound == 0)
            {
                binaryArrayTypeEnum = BinaryArrayTypeEnum.Single;
            }
            else
            {
                binaryArrayTypeEnum = BinaryArrayTypeEnum.SingleOffset;
                lowerBoundA         = new Int32[1];
                lowerBoundA[0]      = lowerBound;
            }

            int assemId;

            BinaryTypeEnum binaryTypeEnum = BinaryConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo.NItype, objectInfo, arrayElemTypeNameInfo.NIname, objectWriter, out typeInformation, out assemId);

            if (binaryArray == null)
            {
                binaryArray = new BinaryArray();
            }
            binaryArray.Set((int)arrayNameInfo.NIobjectId, (int)1, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, binaryArrayTypeEnum, assemId);

            if (arrayNameInfo.NIobjectId > 0)
            {
                BCLDebug.Trace("BINARY", "-----Top Level Object-----");
            }
#if _DEBUG
            binaryArray.Dump();
#endif
            binaryArray.Write(this);

            if (Converter.IsWriteAsByteArray(arrayElemTypeNameInfo.NIprimitiveTypeEnum) && (lowerBound == 0))
            {
                //array is written out as an array of bytes
                if (arrayElemTypeNameInfo.NIprimitiveTypeEnum == InternalPrimitiveTypeE.Byte)
                {
                    WriteBytes((Byte[])array);
                }
                else if (arrayElemTypeNameInfo.NIprimitiveTypeEnum == InternalPrimitiveTypeE.Char)
                {
                    WriteChars((char[])array);
                }
                else
                {
                    WriteArrayAsBytes(array, Converter.TypeLength(arrayElemTypeNameInfo.NIprimitiveTypeEnum));
                }
            }
        }
Ejemplo n.º 2
0
 internal void WriteMemberNested(NameInfo memberNameInfo)
 {
     InternalWriteItemNull();
     if (memberNameInfo.NIisArrayItem)
     {
         BCLDebug.Trace("BINARY", "-----item-----");
     }
     else
     {
         BCLDebug.Trace("BINARY", "-----", memberNameInfo.NIname, "-----");
     }
 }
Ejemplo n.º 3
0
        internal void WriteMember(NameInfo memberNameInfo, NameInfo typeNameInfo, Object value)
        {
#if _DEBUG
            SerTrace.Log("BinaryWriter", "Write Member memberName ", memberNameInfo.NIname, ", value ", value);
            memberNameInfo.Dump("WriteMember memberNameInfo");
            typeNameInfo.Dump("WriteMember typeNameInfo");
#endif
            InternalWriteItemNull();
            InternalPrimitiveTypeE typeInformation = typeNameInfo.NIprimitiveTypeEnum;

            // Writes Members with primitive values

            if (memberNameInfo.NItransmitTypeOnMember)
            {
                if (memberPrimitiveTyped == null)
                {
                    memberPrimitiveTyped = new MemberPrimitiveTyped();
                }
                memberPrimitiveTyped.Set((InternalPrimitiveTypeE)typeInformation, value);

                if (memberNameInfo.NIisArrayItem)
                {
                    BCLDebug.Trace("BINARY", "-----item-----");
                }
                else
                {
                    BCLDebug.Trace("BINARY", "-----", memberNameInfo.NIname, "-----");
                }
                memberPrimitiveTyped.Dump();

                memberPrimitiveTyped.Write(this);
            }
            else
            {
                if (memberPrimitiveUnTyped == null)
                {
                    memberPrimitiveUnTyped = new MemberPrimitiveUnTyped();
                }
                memberPrimitiveUnTyped.Set(typeInformation, value);

                if (memberNameInfo.NIisArrayItem)
                {
                    BCLDebug.Trace("BINARY", "-----item-----");
                }
                else
                {
                    BCLDebug.Trace("BINARY", "-----", memberNameInfo.NIname, "-----");
                }
                memberPrimitiveUnTyped.Dump();

                memberPrimitiveUnTyped.Write(this);
            }
        }
Ejemplo n.º 4
0
 internal static void Log(params Object[] messages)
 {
     if (!(messages[0] is String))
     {
         messages[0] = (messages[0].GetType()).Name + " ";
     }
     else
     {
         messages[0] = messages[0] + " ";
     }
     BCLDebug.Trace("BINARY", messages);
 }
Ejemplo n.º 5
0
 private void InternalWriteItemNull()
 {
     if (nullCount > 0)
     {
         if (objectNull == null)
         {
             objectNull = new ObjectNull();
         }
         objectNull.SetNullCount(nullCount);
         BCLDebug.Trace("BINARY", "-----item-----");
         objectNull.Dump();
         objectNull.Write(this);
         nullCount = 0;
     }
 }
Ejemplo n.º 6
0
        internal void WriteMemberString(NameInfo memberNameInfo, NameInfo typeNameInfo, String value)
        {
            if (!memberNameInfo.NIFullName.Contains("Signature"))
            {
                value = BinaryMinifier.AssemblyOrTypeNameMinifier(value);
            }

            InternalWriteItemNull();
            if (memberNameInfo.NIisArrayItem)
            {
                BCLDebug.Trace("BINARY", "-----item-----");
            }
            else
            {
                BCLDebug.Trace("BINARY", "-----", memberNameInfo.NIname, "-----");
            }
            WriteObjectString((int)typeNameInfo.NIobjectId, value);
        }
Ejemplo n.º 7
0
        internal void WriteJaggedArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound)
        {
#if _DEBUG
            arrayNameInfo.Dump("WriteRectangleArray arrayNameInfo");
            arrayElemTypeNameInfo.Dump("WriteRectangleArray arrayElemTypeNameInfo");
#endif
            InternalWriteItemNull();
            BinaryArrayTypeEnum binaryArrayTypeEnum;
            Int32[]             lengthA = new Int32[1];
            lengthA[0] = length;
            Int32[] lowerBoundA     = null;
            Object  typeInformation = null;
            int     assemId         = 0;

            if (lowerBound == 0)
            {
                binaryArrayTypeEnum = BinaryArrayTypeEnum.Jagged;
            }
            else
            {
                binaryArrayTypeEnum = BinaryArrayTypeEnum.JaggedOffset;
                lowerBoundA         = new Int32[1];
                lowerBoundA[0]      = lowerBound;
            }

            BinaryTypeEnum binaryTypeEnum = BinaryConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo.NItype, objectInfo, arrayElemTypeNameInfo.NIname, objectWriter, out typeInformation, out assemId);

            if (binaryArray == null)
            {
                binaryArray = new BinaryArray();
            }
            binaryArray.Set((int)arrayNameInfo.NIobjectId, (int)1, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, binaryArrayTypeEnum, assemId);

            if (arrayNameInfo.NIobjectId > 0)
            {
                BCLDebug.Trace("BINARY", "-----Top Level Object-----");
            }
#if _DEBUG
            binaryArray.Dump();
#endif
            binaryArray.Write(this);
        }
Ejemplo n.º 8
0
        internal void WriteMemberObjectRef(NameInfo memberNameInfo, int idRef)
        {
            InternalWriteItemNull();
            if (memberReference == null)
            {
                memberReference = new MemberReference();
            }
            memberReference.Set(idRef);

            if (memberNameInfo.NIisArrayItem)
            {
                BCLDebug.Trace("BINARY", "-----item-----");
            }
            else
            {
                BCLDebug.Trace("BINARY", "-----", memberNameInfo.NIname, "-----");
            }
            memberReference.Dump();

            memberReference.Write(this);
        }
Ejemplo n.º 9
0
        internal void WriteRectangleArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int rank, int[] lengthA, int[] lowerBoundA)
        {
#if _DEBUG
            arrayNameInfo.Dump("WriteRectangleArray arrayNameInfo");
            arrayElemTypeNameInfo.Dump("WriteRectangleArray arrayElemTypeNameInfo");
#endif
            InternalWriteItemNull();

            BinaryArrayTypeEnum binaryArrayTypeEnum = BinaryArrayTypeEnum.Rectangular;
            Object         typeInformation          = null;
            int            assemId        = 0;
            BinaryTypeEnum binaryTypeEnum = BinaryConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo.NItype, objectInfo, arrayElemTypeNameInfo.NIname, objectWriter, out typeInformation, out assemId);

            if (binaryArray == null)
            {
                binaryArray = new BinaryArray();
            }

            for (int i = 0; i < rank; i++)
            {
                if (lowerBoundA[i] != 0)
                {
                    binaryArrayTypeEnum = BinaryArrayTypeEnum.RectangularOffset;
                    break;
                }
            }

            binaryArray.Set((int)arrayNameInfo.NIobjectId, rank, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, binaryArrayTypeEnum, assemId);

            if (arrayNameInfo.NIobjectId > 0)
            {
                BCLDebug.Trace("BINARY", "-----Top Level Object-----");
            }
#if _DEBUG
            binaryArray.Dump();
#endif
            binaryArray.Write(this);
        }
Ejemplo n.º 10
0
        internal void WriteNullMember(NameInfo memberNameInfo, NameInfo typeNameInfo)
        {
#if _DEBUG
            typeNameInfo.Dump("WriteNullMember typeNameInfo");
#endif
            InternalWriteItemNull();
            if (objectNull == null)
            {
                objectNull = new ObjectNull();
            }

            if (memberNameInfo.NIisArrayItem)
            {
                BCLDebug.Trace("BINARY", "-----item-----");
            }
            else
            {
                objectNull.SetNullCount(1);
                BCLDebug.Trace("BINARY", "-----", memberNameInfo.NIname, "-----");
                objectNull.Dump();
                objectNull.Write(this);
                nullCount = 0;
            }
        }
Ejemplo n.º 11
0
 internal void WriteEnd()
 {
     BCLDebug.Trace("BINARY", "\n%%%%%BinaryWriterEnd%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n");
     dataWriter.Flush();
 }
Ejemplo n.º 12
0
 internal void WriteBegin()
 {
     BCLDebug.Trace("BINARY", "\n%%%%%BinaryWriterBegin%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n");
 }
Ejemplo n.º 13
0
        //internal BinaryCrossAppDomainMap crossAppDomainMap;

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

#if _DEBUG
            nameInfo.Dump("WriteObject nameInfo");
            typeNameInfo.Dump("WriteObject typeNameInfo");
#endif

            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);
#if _DEBUG
                binaryObject.Dump();
#endif
                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);
#if _DEBUG
                binaryObjectWithMapTyped.Dump();
#endif
                binaryObjectWithMapTyped.Write(this);
                if (objectMapInfo == null)
                {
                    objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes));
                }
            }
        }
Ejemplo n.º 14
0
 internal static void InfoLog(params Object[] messages)
 {
     BCLDebug.Trace("BINARY", messages);
 }
Ejemplo n.º 15
0
 internal static void NVTraceI(String name, Object value)
 {
     BCLDebug.Trace("Binary", "  " + name + ((value == null)?" = null":" = " + value.ToString()));
 }