Ejemplo n.º 1
0
        /// <include file='doc\Message.uex' path='docs/doc[@for="Message.Message"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Initializes a new instance of the <see cref='System.Messaging.Message'/> class with an empty body.
        ///    </para>
        /// </devdoc>
        public Message()
        {
            properties = new MessagePropertyVariants();
            receiveCreated = false;
            this.filter = new MessagePropertyFilter();

            //Always add Id
            properties.SetUI1Vector(NativeMethods.MESSAGE_PROPID_MSGID, new byte[MessageIdSize]);
            this.filter.Id = true;
        }
Ejemplo n.º 2
0
        /// <include file='doc\Message.uex' path='docs/doc[@for="Message.Message3"]/*' />
        /// <internalonly/>                
        internal Message(MessagePropertyFilter filter)
        {
            properties = new MessagePropertyVariants();
            receiveCreated = true;
            this.filter = filter;
            if (filter.data1 != 0)
            {
                int data = filter.data1;

                if (0 != (data & MessagePropertyFilter.ACKNOWLEDGEMENT))
                    properties.SetUI2(NativeMethods.MESSAGE_PROPID_CLASS, (short)0);

                if (0 != (data & MessagePropertyFilter.ACKNOWLEDGE_TYPE))
                    properties.SetUI1(NativeMethods.MESSAGE_PROPID_ACKNOWLEDGE, (byte)0);

                if (0 != (data & MessagePropertyFilter.ADMIN_QUEUE))
                {
                    properties.SetString(NativeMethods.MESSAGE_PROPID_ADMIN_QUEUE, new byte[DefaultQueueNameSize * 2]);
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_ADMIN_QUEUE_LEN, DefaultQueueNameSize);
                }
                if (0 != (data & MessagePropertyFilter.BODY))
                {
                    properties.SetUI1Vector(NativeMethods.MESSAGE_PROPID_BODY, new byte[filter.bodySize]);
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_BODY_SIZE, filter.bodySize);
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_BODY_TYPE, 0);
                }
                if (0 != (data & MessagePropertyFilter.LABEL))
                {
                    properties.SetString(NativeMethods.MESSAGE_PROPID_LABEL, new byte[filter.labelSize * 2]);
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_LABEL_LEN, filter.labelSize);
                }
                if (0 != (data & MessagePropertyFilter.ID))
                    properties.SetUI1Vector(NativeMethods.MESSAGE_PROPID_MSGID, new byte[MessageIdSize]);

                if (0 != (data & MessagePropertyFilter.LOOKUP_ID))
                    properties.SetUI8(NativeMethods.MESSAGE_PROPID_LOOKUPID, (long)0);

                if (0 != (data & MessagePropertyFilter.USE_DEADLETTER_QUEUE))
                    properties.SetUI1(NativeMethods.MESSAGE_PROPID_JOURNAL, (byte)0);

                if (0 != (data & MessagePropertyFilter.RESPONSE_QUEUE))
                {
                    properties.SetString(NativeMethods.MESSAGE_PROPID_RESP_QUEUE, new byte[DefaultQueueNameSize * 2]);
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_RESP_QUEUE_LEN, DefaultQueueNameSize);
                }
                //Acknowledgment and MessageType are overloaded in MQ.
                if ((0 == (data & MessagePropertyFilter.ACKNOWLEDGEMENT)) && (0 != (data & MessagePropertyFilter.MESSAGE_TYPE)))
                    properties.SetUI2(NativeMethods.MESSAGE_PROPID_CLASS, (short)0);

                //Journaling and Deadletter are overloaded in MSMQ
                if ((0 == (data & MessagePropertyFilter.USE_DEADLETTER_QUEUE)) && (0 != (data & MessagePropertyFilter.USE_JOURNALING)))
                    properties.SetUI1(NativeMethods.MESSAGE_PROPID_JOURNAL, (byte)0);
            }

            if (filter.data2 != 0)
            {
                int data = filter.data2;
                if (0 != (data & MessagePropertyFilter.APP_SPECIFIC))
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_APPSPECIFIC, 0);
                if (0 != (data & MessagePropertyFilter.ARRIVED_TIME))
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_ARRIVEDTIME, 0);
                if (0 != (data & MessagePropertyFilter.ATTACH_SENDER_ID))
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_SENDERID_TYPE, 0);
                if (0 != (data & MessagePropertyFilter.AUTHENTICATED))
                    properties.SetUI1(NativeMethods.MESSAGE_PROPID_AUTHENTICATED, (byte)0);

                if (0 != (data & MessagePropertyFilter.CONNECTOR_TYPE))
                    properties.SetGuid(NativeMethods.MESSAGE_PROPID_CONNECTOR_TYPE, new byte[GenericIdSize]);
                if (0 != (data & MessagePropertyFilter.CORRELATION_ID))
                    properties.SetUI1Vector(NativeMethods.MESSAGE_PROPID_CORRELATIONID, new byte[MessageIdSize]);
                if (0 != (data & MessagePropertyFilter.CRYPTOGRAPHIC_PROVIDER_NAME))
                {
                    properties.SetString(NativeMethods.MESSAGE_PROPID_PROV_NAME, new byte[DefaultCryptographicProviderNameSize * 2]);
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_PROV_NAME_LEN, DefaultCryptographicProviderNameSize);
                }
                if (0 != (data & MessagePropertyFilter.CRYPTOGRAPHIC_PROVIDER_TYPE))
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_PROV_TYPE, 0);
                if (0 != (data & MessagePropertyFilter.IS_RECOVERABLE))
                    properties.SetUI1(NativeMethods.MESSAGE_PROPID_DELIVERY, (byte)0);
                if (0 != (data & MessagePropertyFilter.DESTINATION_QUEUE))
                {
                    properties.SetString(NativeMethods.MESSAGE_PROPID_DEST_QUEUE, new byte[DefaultQueueNameSize * 2]);
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_DEST_QUEUE_LEN, DefaultQueueNameSize);
                }
                if (0 != (data & MessagePropertyFilter.DIGITAL_SIGNATURE))
                {
                    properties.SetUI1Vector(NativeMethods.MESSAGE_PROPID_SIGNATURE, new byte[DefaultDigitalSignatureSize]);
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_SIGNATURE_LEN, DefaultDigitalSignatureSize);
                }
                if (0 != (data & MessagePropertyFilter.ENCRYPTION_ALGORITHM))
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_ENCRYPTION_ALG, 0);
                if (0 != (data & MessagePropertyFilter.EXTENSION))
                {
                    properties.SetUI1Vector(NativeMethods.MESSAGE_PROPID_EXTENSION, new byte[filter.extensionSize]);
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_EXTENSION_LEN, filter.extensionSize);
                }
                if (0 != (data & MessagePropertyFilter.FOREIGN_ADMIN_QUEUE))
                {
                    properties.SetString(NativeMethods.MESSAGE_PROPID_XACT_STATUS_QUEUE, new byte[DefaultQueueNameSize * 2]);
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_XACT_STATUS_QUEUE_LEN, DefaultQueueNameSize);
                }
                if (0 != (data & MessagePropertyFilter.HASH_ALGORITHM))
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_HASH_ALG, 0);
                if (0 != (data & MessagePropertyFilter.IS_FIRST_IN_TRANSACTION))
                    properties.SetUI1(NativeMethods.MESSAGE_PROPID_FIRST_IN_XACT, (byte)0);
                if (0 != (data & MessagePropertyFilter.IS_LAST_IN_TRANSACTION))
                    properties.SetUI1(NativeMethods.MESSAGE_PROPID_LAST_IN_XACT, (byte)0);
                if (0 != (data & MessagePropertyFilter.PRIORITY))
                    properties.SetUI1(NativeMethods.MESSAGE_PROPID_PRIORITY, (byte)0);
                if (0 != (data & MessagePropertyFilter.SENDER_CERTIFICATE))
                {
                    properties.SetUI1Vector(NativeMethods.MESSAGE_PROPID_SENDER_CERT, new byte[DefaultSenderCertificateSize]);
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_SENDER_CERT_LEN, DefaultSenderCertificateSize);
                }
                if (0 != (data & MessagePropertyFilter.SENDER_ID))
                {
                    properties.SetUI1Vector(NativeMethods.MESSAGE_PROPID_SENDERID, new byte[DefaultSenderIdSize]);
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_SENDERID_LEN, DefaultSenderIdSize);
                }
                if (0 != (data & MessagePropertyFilter.SENT_TIME))
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_SENTTIME, 0);
                if (0 != (data & MessagePropertyFilter.SOURCE_MACHINE))
                    properties.SetGuid(NativeMethods.MESSAGE_PROPID_SRC_MACHINE_ID, new byte[GenericIdSize]);
                if (0 != (data & MessagePropertyFilter.SYMMETRIC_KEY))
                {
                    properties.SetUI1Vector(NativeMethods.MESSAGE_PROPID_DEST_SYMM_KEY, new byte[DefaultSymmetricKeySize]);
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_DEST_SYMM_KEY_LEN, DefaultSymmetricKeySize);
                }
                if (0 != (data & MessagePropertyFilter.TIME_TO_BE_RECEIVED))
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_TIME_TO_BE_RECEIVED, 0);
                if (0 != (data & MessagePropertyFilter.TIME_TO_REACH_QUEUE))
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_TIME_TO_REACH_QUEUE, 0);
                if (0 != (data & MessagePropertyFilter.TRANSACTION_ID))
                    properties.SetUI1Vector(NativeMethods.MESSAGE_PROPID_XACTID, new byte[MessageIdSize]);
                if (0 != (data & MessagePropertyFilter.USE_AUTHENTICATION))
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_AUTH_LEVEL, 0);
                if (0 != (data & MessagePropertyFilter.USE_ENCRYPTION))
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_PRIV_LEVEL, 0);
                if (0 != (data & MessagePropertyFilter.USE_TRACING))
                    properties.SetUI1(NativeMethods.MESSAGE_PROPID_TRACE, (byte)0);
                if (0 != (data & MessagePropertyFilter.VERSION))
                    properties.SetUI4(NativeMethods.MESSAGE_PROPID_VERSION, 0);
            }
        }