本文整理汇总了C#中IMessageContext类的典型用法代码示例。如果您正苦于以下问题:C# IMessageContext类的具体用法?C# IMessageContext怎么用?C# IMessageContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMessageContext类属于命名空间,在下文中一共展示了IMessageContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetMessage
/// <summary>
/// Get a validation message
/// </summary>
/// <param name="context">Context</param>
/// <returns>
/// String if found; otherwise <c>null</c>.
/// </returns>
public string GetMessage(IMessageContext context)
{
if (context.Attribute is CompareAttribute)
return "The {0} and {1} fields to not match.";
return null;
}
开发者ID:NightOwl888,项目名称:ComplexCommerce,代码行数:14,代码来源:MvcValidationMessageProvider.cs
示例2: HeartBeatWorker
/// <summary>
/// Initializes a new instance of the <see cref="HeartBeatWorker" /> class.
/// </summary>
/// <param name="configuration">The configuration.</param>
/// <param name="context">The context.</param>
/// <param name="sendHeartBeat">The send heart beat.</param>
/// <param name="threadPool">The thread pool.</param>
/// <param name="log">The log.</param>
/// <param name="heartBeatNotificationFactory">The heart beat notification factory.</param>
public HeartBeatWorker(IHeartBeatConfiguration configuration,
IMessageContext context,
ISendHeartBeat sendHeartBeat,
IHeartBeatThreadPool threadPool,
ILogFactory log,
IWorkerHeartBeatNotificationFactory heartBeatNotificationFactory)
{
Guard.NotNull(() => configuration, configuration);
Guard.NotNull(() => context, context);
Guard.NotNull(() => sendHeartBeat, sendHeartBeat);
Guard.NotNull(() => threadPool, threadPool);
Guard.NotNull(() => log, log);
Guard.NotNull(() => heartBeatNotificationFactory, heartBeatNotificationFactory);
_context = context;
_checkTimespan = configuration.CheckTime;
_sendHeartbeat = sendHeartBeat;
_smartThreadPool = threadPool;
_logger = log.Create();
_runningLock = new ReaderWriterLockSlim();
_stoppedLock = new ReaderWriterLockSlim();
_cancel = new CancellationTokenSource();
context.WorkerNotification.HeartBeat = heartBeatNotificationFactory.Create(_cancel.Token);
}
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:35,代码来源:HeartBeatWorker.cs
示例3: Command
protected Command(Guid aggregateId, int version, IMessageContext context)
{
AggregateId = aggregateId;
UtcDate = SystemClock.UtcNow;
Version = version;
Metadata = context.Metadata;
}
开发者ID:4deeptech,项目名称:Akka.EventStore.Cqrs.Core,代码行数:7,代码来源:ICommand.cs
示例4: Commit
/// <summary>
/// Commits the processed message, by deleting the message
/// </summary>
/// <param name="context">The context.</param>
public void Commit(IMessageContext context)
{
if (context.MessageId != null && context.MessageId.HasValue)
{
_deleteMessageCommand.Handle(new DeleteMessageCommand((long)context.MessageId.Id.Value));
}
}
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:11,代码来源:CommitMessage.cs
示例5: Handle
/// <summary>
/// Handles processing the specified message with the context
/// </summary>
/// <param name="context">The context.</param>
/// <param name="transportMessage">The transport message.</param>
/// <returns></returns>
public bool Handle(IMessageContext context, IReceivedMessageInternal transportMessage)
{
using (var heartBeat = _heartBeatWorkerFactory.Create(context))
{
try
{
_methodToRun.Handle(transportMessage, context.WorkerNotification);
_commitMessage.Commit(context);
return true;
}
// ReSharper disable once UncatchableException
catch (ThreadAbortException)
{
heartBeat.Stop();
throw;
}
catch (OperationCanceledException)
{
heartBeat.Stop();
throw;
}
catch (Exception exception)
{
heartBeat.Stop();
_messageExceptionHandler.Handle(transportMessage, context, exception);
}
}
return false;
}
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:35,代码来源:ProcessMessage.cs
示例6: ProcessMessage
/// <summary>
/// messaging callback
/// see com.db4o.messaging.MessageRecipient#ProcessMessage()
/// </summary>
public void ProcessMessage(IMessageContext con, object message)
{
if (message is StopServer)
{
Close();
}
}
开发者ID:dcollioni,项目名称:BrMobi,代码行数:11,代码来源:StartServer.cs
示例7: Publish
public void Publish(IMessage message, IMessageContext sender)
{
var messageTpye = message.GetType();
if (handlers.ContainsKey(messageTpye))
{
foreach (var handler in handlers[messageTpye])
{
dynamic instance = handlerFactory(handler);
try
{
if (HasResponse(message))
{
var result = instance.Handle((dynamic)(message.ToPublishedMessage(sender)));
sender.Respond(result);
}
else
instance.Handle((dynamic)(message.ToPublishedMessage(sender)));
}
catch (Exception ex)
{
sender.ErrorFormat("{0} , {1}", ex.Message, ex.StackTrace);
}
}
}
}
开发者ID:Elders,项目名称:Skynet,代码行数:25,代码来源:SkynetPublisher.cs
示例8: Send
/// <summary>
/// Updates the heart beat for a record.
/// </summary>
/// <param name="context">The context.</param>
/// <returns></returns>
public IHeartBeatStatus Send(IMessageContext context)
{
using (_timer.NewContext())
{
return _handler.Send(context);
}
}
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:12,代码来源:ISendHeartBeatDecorator.cs
示例9: Handle
public HandleResult Handle(IMessageContext msg)
{
if (msg.IsInitiallyPolled)
return HandleResult.Ignored;
var update = msg.Update;
if (update.Message.Chat.Id == -1001013065325)
{
var eva = new Regex(@"\b[eе]+[vв]+[aа]+\b", RegexOptions.IgnoreCase);
if (eva.IsMatch(update.Message.Text ?? ""))
{
_ctx.BotApi.SendMessageAsync(-1001013065325, "чо");
return HandleResult.HandledCompletely;
}
if (update.Message.From.Id == 146268050)
{
var roll = new Random().Next(10);
if (roll == 7)
_ctx.BotApi.SendMessageAsync(-1001013065325, "юль, ну впиши по-братски");
return HandleResult.HandledCompletely;
}
}
return HandleResult.Ignored;
}
开发者ID:etherealko,项目名称:Eve,代码行数:28,代码来源:PluginOne.cs
示例10: MoveRecordToErrorQueueCommand
/// <summary>
/// Initializes a new instance of the <see cref="MoveRecordToErrorQueueCommand" /> class.
/// </summary>
/// <param name="exception">The exception.</param>
/// <param name="queueId">The queue identifier.</param>
/// <param name="context">The context.</param>
public MoveRecordToErrorQueueCommand(Exception exception, long queueId, IMessageContext context)
{
Guard.NotNull(() => context, context);
Exception = exception;
QueueId = queueId;
MessageContext = context;
}
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:13,代码来源:MoveRecordToErrorQueueCommand.cs
示例11: Handle
/// <summary>
/// Handles processing the specified message with the context
/// </summary>
/// <param name="context">The context.</param>
/// <param name="transportMessage">The transport message.</param>
/// <returns></returns>
public async Task Handle(IMessageContext context, IReceivedMessageInternal transportMessage)
{
using (var heartBeat = _heartBeatWorkerFactory.Create(context))
{
try
{
await _methodToRun.HandleAsync(transportMessage, context.WorkerNotification).ConfigureAwait(false);
_commitMessage.Commit(context);
}
// ReSharper disable once UncatchableException
catch (ThreadAbortException)
{
heartBeat.Stop();
throw;
}
catch (OperationCanceledException)
{
heartBeat.Stop();
throw;
}
catch (Exception exception)
{
heartBeat.Stop();
_messageExceptionHandler.Handle(transportMessage, context, exception.InnerException ?? exception);
}
}
}
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:33,代码来源:ProcessMessageAsync.cs
示例12: Respond
public Task Respond(ChatContextHolder chatContextHolder, IMessageContext context)
{
return Task.Run(() =>
{
foreach (LightPin pin in _lights)
{
pin.Set(context.Text, _pinManager);
}
LightPin[] allOn = _lights.Where(x => x.ContainsSection(context.Text) && x.IsOn(context.Text)).ToArray();
if (!allOn.Select(x => x.Color).Any())
{
context.Respond(string.Format("{0} lights are now off",
_lights.Where(x => x.ContainsSection(context.Text))
.Select(x => x.Section)
.Distinct()
.StringJoin()));
}
else
{
context.Respond(string.Format("{0} {1} lights are now on",
allOn.Select(x => x.Section).Distinct().StringJoin(),
allOn.Select(x => x.Color).Distinct().StringJoin()));
}
});
}
开发者ID:rolfwessels,项目名称:DarthVaderBuildIndicator,代码行数:25,代码来源:SetIoContext.cs
示例13: GetMessage
/// <summary>
/// Returns the next message, if any.
/// </summary>
/// <param name="context">The context.</param>
/// <returns>
/// A message if one is found; null otherwise
/// </returns>
public IReceivedMessageInternal GetMessage(IMessageContext context)
{
//if stopping, exit now
if (_cancelToken.Tokens.Any(t => t.IsCancellationRequested))
{
return null;
}
//check for a specific MessageID to pull
IMessageId messageId = null;
var rpc = context.Get(_configuration.HeaderNames.StandardHeaders.RpcContext);
if (rpc?.MessageId != null && rpc.MessageId.HasValue)
{
messageId = rpc.MessageId;
}
//ask for the next message, or a specific message if we have a messageID
var receivedTransportMessage =
_receiveMessage.Handle(new ReceiveMessageQuery(messageId, _configuration.Routes));
//if no message (null) run the no message action and return
if (receivedTransportMessage == null)
{
return null;
}
//set the message ID on the context for later usage
context.MessageId = receivedTransportMessage.MesssageId;
return receivedTransportMessage;
}
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:38,代码来源:ReceiveMessage.cs
示例14: End
public void End(IServiceLocator childServiceLocator, IMessageContext messageContext, Exception ex)
{
if (ex == null)
LogMessage("Commit");
else
LogMessage("Rollback, reason: " + ex);
}
开发者ID:jdaigle,项目名称:CWServiceBus,代码行数:7,代码来源:MyOwnUnitOfWork.cs
示例15: ReceiveMessage
/// <summary>
/// Receives a new message.
/// </summary>
/// <param name="context">The context.</param>
/// <returns></returns>
public IReceivedMessageInternal ReceiveMessage(IMessageContext context)
{
context.Commit += ContextOnCommit;
context.Rollback += ContextOnRollback;
context.Cleanup += context_Cleanup;
TimeSpan? timeout = null;
IMessageId messageId = null;
var rpc = context.Get(_headers.StandardHeaders.RpcContext);
if (rpc?.Timeout != null)
{
timeout = rpc.Timeout;
}
if (rpc?.MessageId != null)
{
messageId = rpc.MessageId;
}
using (
var workSub = rpc?.MessageId != null && rpc.MessageId.HasValue
? _workSubFactory.Create(rpc.MessageId)
: _workSubFactory.Create())
{
while (true)
{
if (_cancelWork.Tokens.Any(m => m.IsCancellationRequested))
{
return null;
}
var message = GetMessage(context, messageId);
if (message != null && !message.Expired)
{
return message.Message;
}
if (_cancelWork.Tokens.Any(m => m.IsCancellationRequested))
{
return null;
}
workSub.Reset();
message = GetMessage(context, messageId);
if (message != null && !message.Expired)
{
return message.Message;
}
if (message != null && message.Expired)
{
continue;
}
if (workSub.Wait(timeout))
{
continue;
}
return null;
}
}
}
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:65,代码来源:RedisQueueReceiveMessages.cs
示例16: Handle
/// <summary>
/// Invoked when we have dequeued a message, but a failure occurred during re-assembly.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="exception">The exception.</param>
public void Handle(IMessageContext context, PoisonMessageException exception)
{
if (context.MessageId != null && context.MessageId.HasValue)
{
_commandMoveRecord.Handle(new MoveRecordToErrorQueueCommand((RedisQueueId)context.MessageId));
}
context.MessageId = null;
}
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:13,代码来源:RedisQueueReceivePoisonMessage.cs
示例17: Respond
public Task Respond(ChatContextHolder chatContextHolder, IMessageContext context)
{
var volumeLevel = ValueConverterHelper.ToInt(ExtractStartsWith(context, "set volume"),10);
var result = string.Format("volume set to {0}", volumeLevel);
_textToSpeech.Play(result);
_volumeSetter.SetVolume(volumeLevel);
return context.Respond(result);
}
开发者ID:rolfwessels,项目名称:DarthVaderBuildIndicator,代码行数:8,代码来源:SetVolumeContext.cs
示例18: MessageSender
public MessageSender(IMessageContext context)
{
m_Context = context;
m_MessageBuffer = new ConcurrentQueue<string>();
m_MessageThread = new Thread(OnThreadStarted);
m_MessageThread.Start();
}
开发者ID:anthony-martin,项目名称:Triangles-in-space,代码行数:8,代码来源:MessageSender.cs
示例19: ConvertToDomainEventStream
void IQueueMessageHandler.Handle(QueueMessage queueMessage, IMessageContext context)
{
var message = _jsonSerializer.Deserialize<EventStreamMessage>(Encoding.UTF8.GetString(queueMessage.Body));
var domainEventStreamMessage = ConvertToDomainEventStream(message);
var processContext = new DomainEventStreamProcessContext(this, domainEventStreamMessage, queueMessage, context);
var processingMessage = new ProcessingDomainEventStreamMessage(domainEventStreamMessage, processContext);
_processor.Process(processingMessage);
}
开发者ID:ulswww,项目名称:enode,代码行数:8,代码来源:DomainEventConsumer.cs
示例20: EQueueProcessContext
void IQueueMessageHandler.Handle(QueueMessage queueMessage, IMessageContext context)
{
var applicationMessageType = _typeNameProvider.GetType(queueMessage.Tag);
var message = _jsonSerializer.Deserialize(Encoding.UTF8.GetString(queueMessage.Body), applicationMessageType) as IApplicationMessage;
var processContext = new EQueueProcessContext(queueMessage, context);
var processingMessage = new ProcessingApplicationMessage(message, processContext);
_processor.Process(processingMessage);
}
开发者ID:linkai0924,项目名称:enode,代码行数:8,代码来源:ApplicationMessageConsumer.cs
注:本文中的IMessageContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论