private static ClientMessage ConvertFromOutsideMessage()

in src/Proton.Client/Client/Implementation/ClientMessageSupport.cs [226:311]


      private static ClientMessage<T> ConvertFromOutsideMessage<T>(IMessage<T> source)
      {
         Header header = new()
         {
            Durable = source.Durable,
            Priority = source.Priority,
            TimeToLive = source.TimeToLive,
            FirstAcquirer = source.FirstAcquirer,
            DeliveryCount = source.DeliveryCount
         };

         byte[] userId = source.UserId;

         Properties properties = new()
         {
            MessageId = source.MessageId,
            UserId = userId != null ? ProtonByteBufferAllocator.Instance.Wrap(userId) : null,
            To = source.To,
            Subject = source.Subject,
            ReplyTo = source.ReplyTo,
            CorrelationId = source.CorrelationId,
            ContentType = source.ContentType,
            ContentEncoding = source.ContentEncoding,
            AbsoluteExpiryTime = source.AbsoluteExpiryTime,
            CreationTime = source.CreationTime,
            GroupId = source.GroupId,
            GroupSequence = source.GroupSequence,
            ReplyToGroupId = source.ReplyToGroupId
         };

         MessageAnnotations messageAnnotations;
         if (source.HasAnnotations)
         {
            messageAnnotations = new MessageAnnotations(new Dictionary<Symbol, object>());

            source.ForEachAnnotation((key, value) =>
            {
               messageAnnotations.Value.Add(Symbol.Lookup(key), value);
            });
         }
         else
         {
            messageAnnotations = null;
         }

         ApplicationProperties applicationProperties;
         if (source.HasProperties)
         {
            applicationProperties = new ApplicationProperties(new Dictionary<string, object>());

            source.ForEachProperty((key, value) =>
            {
               applicationProperties.Value.Add(key, value);
            });
         }
         else
         {
            applicationProperties = null;
         }

         Footer footer;
         if (source.HasFooters)
         {
            footer = new Footer(new Dictionary<Symbol, object>());

            source.ForEachFooter((key, value) =>
            {
               footer.Value.Add(Symbol.Lookup(key), value);
            });
         }
         else
         {
            footer = null;
         }

         ClientMessage<T> message = new(CreateSectionFromValue(source.Body))
         {
            Header = header,
            Properties = properties,
            Annotations = messageAnnotations,
            ApplicationProperties = applicationProperties,
            Footer = footer
         };

         return message;
      }