コード例 #1
0
		public DefaultChannelMessageDispatchContext(IMessagingChannel channel, ChannelMessage channelMessage)
		{
			if (channel == null)
				throw new ArgumentNullException("channel");

			if (channelMessage == null)
				throw new ArgumentNullException("channelMessage");

			this.channel = channel;
			this.channelMessage = channelMessage;
		}
コード例 #2
0
		/// <summary>
		/// Initializes a new instance of the ChannelEnvelope class.
		/// </summary>
		/// <param name="message">The message to be dispatched</param>
		/// <param name="recipients">The collection of recipients to which the message will be sent</param>
		public ChannelEnvelope(ChannelMessage message, IEnumerable<Uri> recipients)
			: this()
		{
			if (message == null)
				throw new ArgumentNullException("message");

			if (recipients == null)
				throw new ArgumentNullException("recipients");

			this.Message = message;

			var immutable = new ReadOnlyCollection<Uri>(recipients.Where(x => x != null).ToArray());
			this.Recipients = immutable;

			if (immutable.Count == 0)
				throw new ArgumentException("No recipients were provided.", "recipients");
		}
コード例 #3
0
		public virtual ChannelMessage Build(
			Guid correlationId,
			Uri returnAddress,
			IDictionary<string, string> headers,
			ICollection<object> messages)
		{
			var message = new ChannelMessage(Guid.NewGuid(), correlationId, returnAddress, headers, messages)
			{
				Expiration = DateTime.MaxValue,
				Persistent = true
			};

			var primaryType = message.Messages.Count > 0 ? message.Messages.First().GetType() : null;
			if (primaryType == null)
				return message;

			message.Persistent = !this.transient.Contains(primaryType);

			TimeSpan timeToLive;
			if (this.expirations.TryGetValue(primaryType, out timeToLive))
				message.Expiration = SystemTime.UtcNow + timeToLive;

			return message;
		}
		protected static void Build(IMessagingChannel channel, ChannelMessage channelMessage)
		{
			dispatchContext = new DefaultChannelMessageDispatchContext(channel, channelMessage);
		}