本文整理汇总了C#中IEventHandler.Handle方法的典型用法代码示例。如果您正苦于以下问题:C# IEventHandler.Handle方法的具体用法?C# IEventHandler.Handle怎么用?C# IEventHandler.Handle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEventHandler
的用法示例。
在下文中一共展示了IEventHandler.Handle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DispatchEventToEventHandler
private void DispatchEventToEventHandler(IEventHandler eventHandler, IEvent evnt, int retriedCount, int maxRetryCount)
{
try
{
var eventHandlerTypeName = (eventHandler as IEventHandlerWrapper).GetInnerEventHandler().GetType().FullName;
if (!_eventHandleInfoStore.IsEventHandleInfoExist(evnt.Id, eventHandlerTypeName))
{
eventHandler.Handle(evnt);
_eventHandleInfoStore.AddEventHandleInfo(evnt.Id, eventHandlerTypeName);
}
}
catch (Exception ex)
{
LogError(eventHandler, evnt, ex, retriedCount + 1);
if (retriedCount < maxRetryCount)
{
DispatchEventToEventHandler(eventHandler, evnt, retriedCount + 1, maxRetryCount);
}
}
}
示例2: DispatchEventToHandler
private bool DispatchEventToHandler(IDomainEvent evnt, IEventHandler handler)
{
try
{
var eventHandlerTypeCode = _eventHandlerTypeCodeProvider.GetTypeCode(handler.GetInnerEventHandler().GetType());
if (_eventHandleInfoCache.IsEventHandleInfoExist(evnt.Id, eventHandlerTypeCode)) return true;
if (_eventHandleInfoStore.IsEventHandleInfoExist(evnt.Id, eventHandlerTypeCode)) return true;
handler.Handle(evnt);
_eventHandleInfoStore.AddEventHandleInfo(evnt.Id, eventHandlerTypeCode);
_eventHandleInfoCache.AddEventHandleInfo(evnt.Id, eventHandlerTypeCode);
return true;
}
catch (Exception ex)
{
_logger.Error(string.Format("Exception raised when [{0}] handling [{1}].", handler.GetInnerEventHandler().GetType().Name, evnt.GetType().Name), ex);
return false;
}
}