Ejemplo n.º 1
0
        /// <summary>
        /// Sets up the <see cref="MsgProps"/> ready to read a message
        /// </summary>
        internal static void SetForRead(this MessageProperties msgProps, Properties read)
        {
            Contract.Requires(msgProps != null);

            if ((read & Properties.Class) != 0)
            {
                msgProps.SetUShort(Native.MESSAGE_PROPID_CLASS, 0);
            }

            if ((read & Properties.AcknowledgementTypes) != 0)
            {
                msgProps.SetByte(Native.MESSAGE_PROPID_ACKNOWLEDGE, 0);
            }

            if ((read & Properties.AdministrationQueue) != 0)
            {
                msgProps.SetString(Native.MESSAGE_PROPID_ADMIN_QUEUE, new byte[255 * 2]);
                msgProps.SetUInt(Native.MESSAGE_PROPID_ADMIN_QUEUE_LEN, 255);
            }

            if ((read & Properties.AppSpecific) != 0)
            {
                msgProps.SetUInt(Native.MESSAGE_PROPID_APPSPECIFIC, 0);
            }

            if ((read & Properties.Body) != 0)
            {
                msgProps.SetByteArray(Native.MESSAGE_PROPID_BODY, new byte[1024]); // use default body size
                msgProps.SetUInt(Native.MESSAGE_PROPID_BODY_SIZE, 1024);
                msgProps.SetUInt(Native.MESSAGE_PROPID_BODY_TYPE, 0);
            }

            if ((read & Properties.CorrelationId) != 0)
            {
                msgProps.SetByteArray(Native.MESSAGE_PROPID_CORRELATIONID, new byte[Message.MessageIdSize]);
            }

            if ((read & Properties.Label) != 0)
            {
                msgProps.SetString(Native.MESSAGE_PROPID_LABEL, new byte[255 * 2]);
                msgProps.SetUInt(Native.MESSAGE_PROPID_LABEL_LEN, 255);
            }

            if ((read & Properties.Id) != 0)
            {
                msgProps.SetByteArray(Native.MESSAGE_PROPID_MSGID, new byte[Message.MessageIdSize]);
            }

            if ((read & Properties.LookupId) != 0)
            {
                msgProps.SetULong(Native.MESSAGE_PROPID_LOOKUPID, 0L);
            }

            if ((read & Properties.ResponseQueue) != 0)
            {
                msgProps.SetString(Native.MESSAGE_PROPID_RESP_QUEUE, new byte[255 * 2]);
                msgProps.SetUInt(Native.MESSAGE_PROPID_RESP_QUEUE_LEN, 255);
            }

            if ((read & Properties.Journal) != 0)
            {
                msgProps.SetByte(Native.MESSAGE_PROPID_JOURNAL, 0);
            }

            if ((read & Properties.ArrivedTime) != 0)
            {
                msgProps.SetUInt(Native.MESSAGE_PROPID_ARRIVEDTIME, 0);
            }

            if ((read & Properties.Delivery) != 0)
            {
                msgProps.SetByte(Native.MESSAGE_PROPID_DELIVERY, 0);
            }

            if ((read & Properties.DestinationQueue) != 0)
            {
                msgProps.SetString(Native.MESSAGE_PROPID_DEST_QUEUE, new byte[255 * 2]);
                msgProps.SetUInt(Native.MESSAGE_PROPID_DEST_QUEUE_LEN, 255);
            }

            if ((read & Properties.Extension) != 0)
            {
                msgProps.SetByteArray(Native.MESSAGE_PROPID_EXTENSION, new byte[255]);
                msgProps.SetUInt(Native.MESSAGE_PROPID_EXTENSION_LEN, 255);
            }

            if ((read & Properties.Priority) != 0)
            {
                msgProps.SetByte(Native.MESSAGE_PROPID_PRIORITY, 0);
            }

            if ((read & Properties.SenderIdType) != 0)
            {
                msgProps.SetUInt(Native.MESSAGE_PROPID_SENDERID_TYPE, 0);
            }

            //if ((read & Properties.SENDER_ID) != 0)
            //{
            //    MsgProps.SetByteArray(Native.MESSAGE_PROPID_SENDERID, new byte[DefaultSenderIdSize]);
            //    MsgProps.SetUInt(Native.MESSAGE_PROPID_SENDERID_LEN, DefaultSenderIdSize);
            //}

            if ((read & Properties.SentTime) != 0)
            {
                msgProps.SetUInt(Native.MESSAGE_PROPID_SENTTIME, 0);
            }

            if ((read & Properties.SourceMachine) != 0)
            {
                msgProps.SetGuid(Native.MESSAGE_PROPID_SRC_MACHINE_ID, new byte[Message.GenericIdSize]);
            }

            if ((read & Properties.TimeToBeReceived) != 0)
            {
                msgProps.SetUInt(Native.MESSAGE_PROPID_TIME_TO_BE_RECEIVED, 0);
            }

            if ((read & Properties.TimeToReachQueue) != 0)
            {
                msgProps.SetUInt(Native.MESSAGE_PROPID_TIME_TO_REACH_QUEUE, 0);
            }

            if ((read & Properties.TransactionId) != 0)
            {
                msgProps.SetByteArray(Native.MESSAGE_PROPID_XACTID, new byte[Message.MessageIdSize]);
            }

            if ((read & Properties.TransactionAbortCount) != 0)
            {
                msgProps.SetUInt(Native.MESSAGE_PROPID_ABORT_COUNT, 0);
            }

            if ((read & Properties.TransactionMoveCount) != 0)
            {
                msgProps.SetUInt(Native.MESSAGE_PROPID_MOVE_COUNT, 0);
            }

            if ((read & Properties.TransactionFirst) != 0)
            {
                msgProps.SetByte(Native.MESSAGE_PROPID_FIRST_IN_XACT, 0);
            }

            if ((read & Properties.TransactionLast) != 0)
            {
                msgProps.SetByte(Native.MESSAGE_PROPID_LAST_IN_XACT, 0);
            }
        }
Ejemplo n.º 2
0
 public Message() : this(new MessageProperties())
 {
     // always add Id so we can read it after send
     Props.SetByteArray(Native.MESSAGE_PROPID_MSGID, new byte[MessageIdSize]);
 }