Esempio n. 1
0
        /// <summary>
        /// Initializes a message with an AmqpValue body. The body must be a defined AMQP type.
        /// </summary>
        /// <param name="body">the object stored in the AmqpValue section.</param>
        public Message(object body)
        {
#if (NETFX || NETFX40 || NETFX35)
            this.BodySection = new AmqpValue<object>(body);
#else
            this.BodySection = new AmqpValue() { Value = body };
#endif
        }
Esempio n. 2
0
        static int GetEstimatedBodySize(RestrictedDescribed body)
        {
            var data = body as Data;
            if (data != null)
            {
                if (data.Buffer != null)
                {
                    return data.Buffer.Length;
                }
                else
                {
                    return data.Binary.Length;
                }
            }

            var value = body as AmqpValue;
            if (value != null)
            {
                var b = value.Value as byte[];
                if (b != null)
                {
                    return b.Length;
                }

                var f = value.Value as ByteBuffer;
                if (f != null)
                {
                    return f.Length;
                }
            }

            return 64;
        }
Esempio n. 3
0
        // Transport layer should call Codec to encode/decode frames. It ensures that
        // all dependant static fields in other class are initialized correctly.
        // NETMF does not track cross-class static field/ctor dependancies

        public static void Encode(RestrictedDescribed command, ByteBuffer buffer)
        {
            Fx.Assert(command != null, "command is null!");
            command.Encode(buffer);
        }
Esempio n. 4
0
 static void EncodeIfNotNull(RestrictedDescribed section, ByteBuffer buffer)
 {
     if (section != null)
     {
         section.Encode(buffer);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a message with an AmqpValue body. The body must be a defined AMQP type.
 /// </summary>
 /// <param name="body">the object stored in the AmqpValue section.</param>
 public Message(object body)
 {
     this.BodySection = new AmqpValue() { Value = body };
 }