Example #1
0
        public void SetObject(object o)
        {
            if (o == null)
            {
                amqpMessage.BodySection = MessageSupport.NULL_AMQP_VALUE_BODY;
            }
            else if (IsNMSObjectTypeSupported(o))
            {
                object value = null;
                if (o is IList)
                {
                    value = ConversionSupport.ListToAmqp(o as IList);
                }
                else if (o is IPrimitiveMap)
                {
                    value = ConversionSupport.NMSMapToAmqp(o as IPrimitiveMap);
                }
                else
                {
                    value = o;
                }
                // to copy the object being set encode a message then decode and take body
                Amqp.Message copy   = new Amqp.Message(value);
                ByteBuffer   buffer = copy.Encode();
                copy = Message.Decode(buffer);

                amqpMessage.BodySection = new AmqpValue {
                    Value = copy.Body
                };
            }
            else
            {
                throw new ArgumentException("Encoding unexpected object type: " + o.GetType().Name);
            }
        }
Example #2
0
        /// <summary>
        /// Sets associate value to the underlying map implementation.
        /// </summary>
        /// <param name="key">Key to associated value.</param>
        /// <param name="value">Value to set.</param>
        protected override void SetObjectProperty(string key, object value)
        {
            object objval = value;

            if (objval is IDictionary)
            {
                objval = ConversionSupport.MapToAmqp(value as IDictionary);
            }
            else if (objval is IList || objval is IList <object> )
            {
                objval = ConversionSupport.ListToAmqp(value as IList);
            }
            this.value[key] = objval;
        }