Apache.NMS.ActiveMQ.Commands.ActiveMQStreamMessage.WriteObject C# (CSharp) Method

WriteObject() public method

public WriteObject ( Object value ) : void
value Object
return void
        public void WriteObject(Object value)
        {
            InitializeWriting();
            if( value is System.Byte )
            {
                this.WriteByte( (byte) value );
            }
            else if( value is Char )
            {
                this.WriteChar( (char) value );
            }
            else if( value is Boolean )
            {
                this.WriteBoolean( (bool) value );
            }
            else if( value is Int16 )
            {
                this.WriteInt16( (short) value );
            }
            else if( value is Int32 )
            {
                this.WriteInt32( (int) value );
            }
            else if( value is Int64 )
            {
                this.WriteInt64( (long) value );
            }
            else if( value is Single )
            {
                this.WriteSingle( (float) value );
            }
            else if( value is Double )
            {
                this.WriteDouble( (double) value );
            }
            else if( value is byte[] )
            {
                this.WriteBytes( (byte[]) value );
            }
            else if( value is String )
            {
                this.WriteString( (string) value );
            }
            else
            {
                throw new MessageFormatException("Cannot write non-primitive type:" + value.GetType());
            }
        }

Usage Example

 public void TestClearBody()
 {
     ActiveMQStreamMessage streamMessage = new ActiveMQStreamMessage();
     try
     {
         streamMessage.WriteObject((Int64) 2);
         streamMessage.ClearBody();
         Assert.IsFalse(streamMessage.ReadOnlyBody);
         streamMessage.WriteObject((Int64) 2);
         streamMessage.ReadObject();
         Assert.Fail("should throw exception");
     }
     catch(MessageNotReadableException)
     {
     }
     catch(MessageNotWriteableException)
     {
         Assert.Fail("should be writeable");
     }
 }
All Usage Examples Of Apache.NMS.ActiveMQ.Commands.ActiveMQStreamMessage::WriteObject