private uint ComputeSize()

in src/Proton.TestPeer/Codec/Impl/ArrayElement.cs [400:462]


      private uint ComputeSize()
      {
         ConstructorType oldConstructorType;
         uint bodySize;
         uint count = 0;
         do
         {
            bodySize = 1; // data type constructor
            oldConstructorType = ConstructorType;
            IElement element = first;
            while (element != null)
            {
               count++;
               bodySize += element.GetSize();
               element = element.Next;
            }
         } while (oldConstructorType != ConstructorType);

         if (IsDescribed)
         {
            bodySize++; // 00 instruction
            if (count != 0)
            {
               count--;
            }
         }

         if (IsElementOfArray())
         {
            ArrayElement parent = (ArrayElement)Parent;
            if (parent.ConstructorType == ConstructorType.Small)
            {
               if (count <= 255 && bodySize <= 254)
               {
                  bodySize += 2;
               }
               else
               {
                  parent.ConstructorType = ConstructorType.Large;
                  bodySize += 8;
               }
            }
            else
            {
               bodySize += 8;
            }
         }
         else
         {

            if (count <= 255 && bodySize <= 254)
            {
               bodySize += 3;
            }
            else
            {
               bodySize += 9;
            }

         }

         return bodySize;
      }