public virtual bool ValuesAreEqual(MarshallingInformation mi1, MarshallingInformation mi2){
   if (mi1 == mi2) return true;
   if (mi1 == null || mi2 == null) return false;
   if (mi1.Class != mi2.Class) return false;
   if (mi1.Cookie != mi2.Cookie) return false;
   if (mi1.ElementSize != mi2.ElementSize) return false;
   if (mi1.ElementType != mi2.ElementType) return false;
   if (mi1.NativeType != mi2.NativeType) return false;
   if (mi1.NumberOfElements != mi2.NumberOfElements) return false;
   if (mi1.ParamIndex != mi2.ParamIndex) return false;
   if (mi1.Size != mi2.Size) return false;
   return true;
 }
Example #2
0
 private MarshallingInformation GetMarshallingInformation(int parentCodedIndex)
 {
     FieldMarshalRow[] mtypes = this.tables.FieldMarshalTable;
     bool sorted = (this.sortedTablesMask >> (int)TableIndices.FieldMarshal) % 2 == 1;
     int i = 0, n = mtypes.Length, j = n - 1;
     if (n == 0) return null;
     if (sorted)
     {
         while (i < j)
         {
             int k = (i + j) / 2;
             if (mtypes[k].Parent < parentCodedIndex)
                 i = k + 1;
             else
                 j = k;
         }
         while (i > 0 && mtypes[i - 1].Parent == parentCodedIndex) i--;
     }
     else
         for (; i < j; i++)
             if (mtypes[i].Parent == parentCodedIndex) break;
     FieldMarshalRow fmr = mtypes[i];
     if (fmr.Parent != parentCodedIndex) return null;
     MarshallingInformation result = new MarshallingInformation();
     int blobSize = 0;
     MemoryCursor c = this.tables.GetBlobCursor(fmr.NativeType, out blobSize);
     int initialPosition = c.Position;
     result.NativeType = (NativeType)c.ReadByte();
     if (result.NativeType == NativeType.CustomMarshaler)
     {
         c.ReadUInt16(); //Skip over 0
         result.Class = ReadSerString(c);
         result.Cookie = ReadSerString(c);
     }
     else if (blobSize > 1)
     {
         if (result.NativeType == NativeType.LPArray)
         {
             result.ElementType = (NativeType)c.ReadByte();
             result.ParamIndex = -1;
             int bytesRead = 2;
             if (bytesRead < blobSize)
             {
                 int pos = c.Position;
                 result.ParamIndex = c.ReadCompressedInt();
                 bytesRead += c.Position - pos;
                 if (bytesRead < blobSize)
                 {
                     pos = c.Position;
                     result.ElementSize = c.ReadCompressedInt();
                     bytesRead += c.Position - pos;
                     if (bytesRead < blobSize)
                         result.NumberOfElements = c.ReadCompressedInt();
                 }
             }
         }
         else if (result.NativeType == NativeType.SafeArray)
         {
             result.ElementType = (NativeType)c.ReadByte(); //Actually a variant type. TODO: what about VT_VECTOR VT_ARRAY and VT_BYREF?
             if (c.Position < initialPosition + blobSize - 1)
                 result.Class = ReadSerString(c);
         }
         else
         {
             result.Size = c.ReadCompressedInt();
             if (result.NativeType == NativeType.ByValArray)
             {
                 if (blobSize > 2)
                     result.ElementType = (NativeType)c.ReadByte();
                 else
                     result.ElementType = NativeType.NotSpecified;
             }
         }
     }
     return result;
 }