当前位置: 首页>>代码示例>>C#>>正文


C# IMessage.SetHeader方法代码示例

本文整理汇总了C#中IMessage.SetHeader方法的典型用法代码示例。如果您正苦于以下问题:C# IMessage.SetHeader方法的具体用法?C# IMessage.SetHeader怎么用?C# IMessage.SetHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMessage的用法示例。


在下文中一共展示了IMessage.SetHeader方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetUp

        public void SetUp()
        {
            var bus = MockRepository.GenerateStub<IBus>();

            headerManager = new MessageHeaderManager();

            bus.Stub(x => x.CurrentMessageContext).Return(new FakeMessageConext
                                                              {
                                                                  Id = idOfIncommingMessage
                                                              });
            ExtensionMethods.SetHeaderAction = headerManager.SetHeader;
            ExtensionMethods.GetHeaderAction = headerManager.GetHeader;

            incomingMessage = new TestMessage();

            incomingMessage.SetOriginatingSiteHeader(originatingSite);

            addressOfOriginatingEndpoint = "EnpointLocatedInSiteA";
            incomingMessage.SetHeader("ReturnAddress",addressOfOriginatingEndpoint);

            gatewayHeaderManager = new GatewayHeaderManager
                                       {
                                           Bus = bus
                                       };

            gatewayHeaderManager.MutateIncoming(incomingMessage);

            responseMessage = new TransportMessage
            {
                Headers = new Dictionary<string, string>(),
                CorrelationId = idOfIncommingMessage
            };
        }
开发者ID:Jpattom,项目名称:NServiceBus,代码行数:33,代码来源:When_receiving_a_message_from_another_site.cs

示例2: AppendHeaders

 private static void AppendHeaders(IMessage message, IEnumerable<KeyValuePair<string, object>> headers)
 {
     headers = headers.Where(x => x.Key.StartsWith(BusPrefixKey));
     foreach (var header in headers)
     {
         var key = header.Key.Substring(BusPrefixKey.Length);
         var value = (header.Value ?? string.Empty).ToString();
         message.SetHeader(key, value);
     }
 }
开发者ID:MattCollinge,项目名称:EventStore-Performance-Tests,代码行数:10,代码来源:NServiceBusDispatcher.cs

示例3: using

        IMessage IMutateOutgoingMessages.MutateOutgoing(IMessage message)
        {
            var timeToBeReceived = message.TimeToBeReceived();

            using (new TransactionScope(TransactionScopeOption.Suppress))
                foreach (var dataBusProperty in message.DataBusPropertiesWithValues())
                {
                    using (var stream = new MemoryStream())
                    {
                        serializer.Serialize(dataBusProperty.GetValue(), stream);
                        stream.Position = 0;

                        dataBusProperty.Key = dataBus.Put(stream, timeToBeReceived);

                        //we use the headers to in order to allow the infrastructure (eg. the gateway) to modify the actual key
                        message.SetHeader(DATABUS_PREFIX + dataBusProperty.Key, dataBusProperty.Key);

                    }
                }

            return message;
        }
开发者ID:rsummer,项目名称:NServiceBus,代码行数:22,代码来源:DataBusMessageMutator.cs

示例4: AddHeaders

 /// <summary>
 /// Adds the headers.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="data">The data.</param>
 public void AddHeaders (IMessage message, IAdditionalMessageData data)
 {
     message.SetHeader(_headers.StandardHeaders.FirstPossibleDeliveryDate, new ValueTypeWrapper<DateTime>(_getFirstMessageDeliveryTime.GetTime(message, data)));
 }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:9,代码来源:AddStandardMessageHeaders.cs

示例5: Push

        internal static void Push(RtmpConnection connection, IMessage message, IMessageClient messageClient)
        {
            if (connection != null)
            {
                object response = message;
                if (message is BinaryMessage)
                {
                    BinaryMessage binaryMessage = message as BinaryMessage;
                    binaryMessage.Update(messageClient);
                    byte[] binaryContent = binaryMessage.body as byte[];
                    //byte[] destClientBinaryId = messageClient.GetBinaryId();
                    //Array.Copy(destClientBinaryId, 0, binaryContent, binaryMessage.PatternPosition, destClientBinaryId.Length);

                    RawBinary result = new RawBinary(binaryContent);
                    response = result;
                }
                else
                {
                    //This should be a clone of the original message
                    message.SetHeader(MessageBase.DestinationClientIdHeader, messageClient.ClientId);
                    message.clientId = messageClient.ClientId;
                }

                RtmpChannel channel = connection.GetChannel(3);
                FlexInvoke reply = new FlexInvoke();
                Call call = new Call("receive", new object[] { response });
                reply.ServiceCall = call;
                //reply.Cmd = "receive";
                //reply.Response = response;
                reply.InvokeId = connection.InvokeId;
                channel.Write(reply);
            }
        }
开发者ID:apakian,项目名称:fluorinefx,代码行数:33,代码来源:BaseRtmpHandler.cs

示例6: MutateOutgoing

 public IMessage MutateOutgoing(IMessage message)
 {
     if(message is ICommand)
         message.SetHeader("CommandId",Guid.NewGuid().ToString());
     return message;
 }
开发者ID:andreasohlund,项目名称:Blog,代码行数:6,代码来源:CommandGuidGenerator.asax.cs

示例7: Send

        /// <summary>
        /// Sends the specified message.
        /// </summary>
        /// <param name="messageToSend">The message to send.</param>
        /// <param name="data">The data.</param>
        /// <returns></returns>
        /// <exception cref="DotNetWorkQueueException">An error occurred while sending a message</exception>
        public IQueueOutputMessage Send(IMessage messageToSend, IAdditionalMessageData data)
        {
            try
            {
                //TODO - temp - fail all messages with routes, as they are not supported yet
                if (!string.IsNullOrEmpty(data.Route))
                {
                    throw new NotImplementedException("Redis transport does not yet support routes");
                }

                //correlationID must be stored as a message header
                messageToSend.SetHeader(_headers.CorelationId, new RedisQueueCorrelationIdSerialized((Guid)data.CorrelationId.Id.Value));

                var messageId = _sendMessage.Handle(new SendMessageCommand(messageToSend, data));
                if (messageId == "JobAlreadyExists")
                {
                    return new QueueOutputMessage(_sentMessageFactory.Create(null, data.CorrelationId), new DotNetWorkQueueException("Failed to enqueue a record. The job already exists"));
                }
                return new QueueOutputMessage(_sentMessageFactory.Create(new RedisQueueId(messageId), data.CorrelationId));
            }
            catch (Exception exception)
            {
                return new QueueOutputMessage(_sentMessageFactory.Create(null, data.CorrelationId), exception);
            }
        }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:32,代码来源:RedisQueueSend.cs


注:本文中的IMessage.SetHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。