123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531 |
- //------------------------------------------------------------------------------
- // <copyright file="DefaultPropertiesToSend.cs" company="Microsoft">
- // Copyright (c) Microsoft Corporation. All rights reserved.
- // </copyright>
- //------------------------------------------------------------------------------
- using System;
- using System.ComponentModel;
- using System.Diagnostics.CodeAnalysis;
- namespace Experimental.System.Messaging
- {
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend"]/*' />
- /// <devdoc>
- /// <para>
- /// Specifies the default property values that will be used when
- /// sending objects using the message queue.
- /// </para>
- /// </devdoc>
- [TypeConverter(typeof(ExpandableObjectConverter))]
- public class DefaultPropertiesToSend
- {
- private Message cachedMessage = new Message();
- private bool designMode;
- private MessageQueue cachedAdminQueue;
- private MessageQueue cachedResponseQueue;
- private MessageQueue cachedTransactionStatusQueue;
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.DefaultPropertiesToSend"]/*' />
- /// <devdoc>
- /// <para>
- /// Initializes a new instance of the <see cref='System.Messaging.DefaultPropertiesToSend'/>
- /// class.
- /// </para>
- /// </devdoc>
- public DefaultPropertiesToSend()
- {
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.DefaultPropertiesToSend1"]/*' />
- /// <internalonly/>
- internal DefaultPropertiesToSend(bool designMode)
- {
- this.designMode = designMode;
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.AcknowledgeTypes"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets
- /// or sets the type of acknowledgement message to be returned to the sending
- /// application.
- /// </para>
- /// </devdoc>
- [DefaultValueAttribute(AcknowledgeTypes.None), MessagingDescription(Res.MsgAcknowledgeType)]
- public AcknowledgeTypes AcknowledgeType
- {
- get
- {
- return this.cachedMessage.AcknowledgeType;
- }
- set
- {
- this.cachedMessage.AcknowledgeType = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.AdministrationQueue"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets or sets the queue used for acknowledgement messages
- /// generated by the application. This is the queue that
- /// will receive the acknowledgment message for the message you are about to
- /// send.
- /// </para>
- /// </devdoc>
- [DefaultValueAttribute(null), MessagingDescription(Res.MsgAdministrationQueue)]
- public MessageQueue AdministrationQueue
- {
- get
- {
- if (this.designMode)
- {
- if (this.cachedAdminQueue != null && this.cachedAdminQueue.Site == null)
- this.cachedAdminQueue = null;
- return this.cachedAdminQueue;
- }
- return this.cachedMessage.AdministrationQueue;
- }
- set
- {
- //The format name of this queue shouldn't be
- //resolved at desgin time, but it should at runtime.
- if (this.designMode)
- this.cachedAdminQueue = value;
- else
- this.cachedMessage.AdministrationQueue = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.AppSpecific"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets or sets application-generated information.
- ///
- /// </para>
- /// </devdoc>
- [DefaultValueAttribute(0), MessagingDescription(Res.MsgAppSpecific)]
- public int AppSpecific
- {
- get
- {
- return this.cachedMessage.AppSpecific;
- }
- set
- {
- this.cachedMessage.AppSpecific = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.AttachSenderId"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets or sets a value indicating if the sender ID is to be attached to the
- /// message.
- ///
- /// </para>
- /// </devdoc>
- [DefaultValueAttribute(true), MessagingDescription(Res.MsgAttachSenderId)]
- public bool AttachSenderId
- {
- get
- {
- return this.cachedMessage.AttachSenderId;
- }
- set
- {
- this.cachedMessage.AttachSenderId = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.CachedMessage"]/*' />
- /// <internalonly/>
- internal Message CachedMessage
- {
- get
- {
- return this.cachedMessage;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.EncryptionAlgorithm"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets or sets the encryption algorithm used to encrypt the body of a
- /// private message.
- ///
- /// </para>
- /// </devdoc>
- [DefaultValueAttribute(EncryptionAlgorithm.Rc2), MessagingDescription(Res.MsgEncryptionAlgorithm)]
- public EncryptionAlgorithm EncryptionAlgorithm
- {
- get
- {
- return this.cachedMessage.EncryptionAlgorithm;
- }
- set
- {
- this.cachedMessage.EncryptionAlgorithm = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.Extension"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets or sets additional information associated with the message.
- ///
- /// </para>
- /// </devdoc>
- [Editor("System.ComponentModel.Design.ArrayEditor, " + AssemblyRef.SystemDesign, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing),
- MessagingDescription(Res.MsgExtension)]
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
- [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
- public byte[] Extension
- {
- get
- {
- return this.cachedMessage.Extension;
- }
- set
- {
- this.cachedMessage.Extension = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.HashAlgorithm"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets or sets the hashing algorithm used when
- /// authenticating
- /// messages.
- ///
- /// </para>
- /// </devdoc>
- [DefaultValueAttribute(HashAlgorithm.Md5), MessagingDescription(Res.MsgHashAlgorithm)]
- public HashAlgorithm HashAlgorithm
- {
- get
- {
- return this.cachedMessage.HashAlgorithm;
- }
- set
- {
- this.cachedMessage.HashAlgorithm = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.Label"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets or sets the message label.
- ///
- /// </para>
- /// </devdoc>
- [DefaultValueAttribute(""), MessagingDescription(Res.MsgLabel)]
- public string Label
- {
- get
- {
- return this.cachedMessage.Label;
- }
- set
- {
- this.cachedMessage.Label = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.Priority"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets or sets the message priority.
- /// </para>
- /// </devdoc>
- [DefaultValueAttribute(MessagePriority.Normal), MessagingDescription(Res.MsgPriority)]
- public MessagePriority Priority
- {
- get
- {
- return this.cachedMessage.Priority;
- }
- set
- {
- this.cachedMessage.Priority = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.Recoverable"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets or sets a value indicating whether the message is
- /// guaranteed to be delivered in the event
- /// of a computer failure or network problem.
- ///
- /// </para>
- /// </devdoc>
- [DefaultValueAttribute(false), MessagingDescription(Res.MsgRecoverable)]
- public bool Recoverable
- {
- get
- {
- return this.cachedMessage.Recoverable;
- }
- set
- {
- this.cachedMessage.Recoverable = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.ResponseQueue"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets or sets the queue which receives application-generated response
- /// messages.
- ///
- /// </para>
- /// </devdoc>
- [DefaultValueAttribute(null), MessagingDescription(Res.MsgResponseQueue)]
- public MessageQueue ResponseQueue
- {
- get
- {
- if (this.designMode)
- return this.cachedResponseQueue;
- return this.cachedMessage.ResponseQueue;
- }
- set
- {
- //The format name of this queue shouldn't be
- //resolved at desgin time, but it should at runtime.
- if (this.designMode)
- this.cachedResponseQueue = value;
- else
- this.cachedMessage.ResponseQueue = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.TimeToBeReceived"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets or sets the time limit for the message to be
- /// retrieved from
- /// the target queue.
- /// </para>
- /// </devdoc>
- [TypeConverter(typeof(System.Messaging.Design.TimeoutConverter)),
- MessagingDescription(Res.MsgTimeToBeReceived)]
- public TimeSpan TimeToBeReceived
- {
- get
- {
- return this.cachedMessage.TimeToBeReceived;
- }
- set
- {
- this.cachedMessage.TimeToBeReceived = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.TimeToReachQueue"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets or sets the time limit for the message to
- /// reach the queue.
- ///
- /// </para>
- /// </devdoc>
- [TypeConverter(typeof(System.Messaging.Design.TimeoutConverter)),
- MessagingDescription(Res.MsgTimeToReachQueue)]
- public TimeSpan TimeToReachQueue
- {
- get
- {
- return this.cachedMessage.TimeToReachQueue;
- }
- set
- {
- this.cachedMessage.TimeToReachQueue = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.TransactionStatusQueue"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets the transaction status queue on the source computer.
- ///
- /// </para>
- /// </devdoc>
- [DefaultValueAttribute(null), MessagingDescription(Res.MsgTransactionStatusQueue)]
- public MessageQueue TransactionStatusQueue
- {
- get
- {
- if (this.designMode)
- return this.cachedTransactionStatusQueue;
- return this.cachedMessage.TransactionStatusQueue;
- }
- set
- {
- //The format name of this queue shouldn't be
- //resolved at desgin time, but it should at runtime.
- if (this.designMode)
- this.cachedTransactionStatusQueue = value;
- else
- this.cachedMessage.TransactionStatusQueue = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.UseAuthentication"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets or sets a value indicating whether the message must be authenticated.
- /// </para>
- /// </devdoc>
- [DefaultValueAttribute(false), MessagingDescription(Res.MsgUseAuthentication)]
- public bool UseAuthentication
- {
- get
- {
- return this.cachedMessage.UseAuthentication;
- }
- set
- {
- this.cachedMessage.UseAuthentication = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.UseDeadLetterQueue"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets or sets a value indicating whether a copy of the message that could not
- /// be delivered should be sent to a dead-letter queue.
- /// </para>
- /// </devdoc>
- [DefaultValueAttribute(false), MessagingDescription(Res.MsgUseDeadLetterQueue)]
- public bool UseDeadLetterQueue
- {
- get
- {
- return this.cachedMessage.UseDeadLetterQueue;
- }
- set
- {
- this.cachedMessage.UseDeadLetterQueue = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.UseEncryption"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets or sets a value indicating whether to encrypt private messages.
- /// </para>
- /// </devdoc>
- [DefaultValueAttribute(false), MessagingDescription(Res.MsgUseEncryption)]
- public bool UseEncryption
- {
- get
- {
- return this.cachedMessage.UseEncryption;
- }
- set
- {
- this.cachedMessage.UseEncryption = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.UseJournalQueue"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets or sets a value indicating whether a copy of the message should be kept
- /// in a machine journal on the originating computer.
- /// </para>
- /// </devdoc>
- [DefaultValueAttribute(false), MessagingDescription(Res.MsgUseJournalQueue)]
- public bool UseJournalQueue
- {
- get
- {
- return this.cachedMessage.UseJournalQueue;
- }
- set
- {
- this.cachedMessage.UseJournalQueue = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.UseTracing"]/*' />
- /// <devdoc>
- /// <para>
- /// Gets or sets a value indicating whether to trace a message as it moves toward
- /// its destination queue.
- /// </para>
- /// </devdoc>
- [DefaultValueAttribute(false), MessagingDescription(Res.MsgUseTracing)]
- public bool UseTracing
- {
- get
- {
- return this.cachedMessage.UseTracing;
- }
- set
- {
- this.cachedMessage.UseTracing = value;
- }
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.ShouldSerializeTimeToBeReceived"]/*' />
- /// <internalonly/>
- private bool ShouldSerializeTimeToBeReceived()
- {
- if (TimeToBeReceived == Message.InfiniteTimeout)
- return false;
- return true;
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.ShouldSerializeTimeToReachQueue"]/*' />
- /// <internalonly/>
- private bool ShouldSerializeTimeToReachQueue()
- {
- if (TimeToReachQueue == Message.InfiniteTimeout)
- return false;
- return true;
- }
- /// <include file='doc\DefaultPropertiesToSend.uex' path='docs/doc[@for="DefaultPropertiesToSend.ShouldSerializeExtension"]/*' />
- /// <internalonly/>
- private bool ShouldSerializeExtension()
- {
- if (Extension != null && Extension.Length > 0)
- {
- return true;
- }
- return false;
- }
- }
- }
|