本文整理汇总了C#中IEvent.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IEvent.GetType方法的具体用法?C# IEvent.GetType怎么用?C# IEvent.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEvent
的用法示例。
在下文中一共展示了IEvent.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Flow
public void Flow(IEvent @event)
{
var eventsToFlow = new List<IEvent>();
foreach (var pipelet in pipelets)
{
log.DebugFormat("Flowing {0} to {1}", @event.GetType(), pipelet.GetType());
var resultingEvents = pipelet.Flow(@event);
if (resultingEvents.Any(e => e.GetType() != typeof (NoopEvent)))
{
log.InfoFormat("Adding {0} events to the pipeline for later flowing, after flowing {1} to {2}",
resultingEvents.Count(),
@event.GetType(),
pipelet.GetType());
eventsToFlow.AddRange(resultingEvents);
}
}
log.DebugFormat("Flowing resulting events to the pipeline. There are {0} events to reflow",
eventsToFlow.Count);
foreach (var eventToFlow in eventsToFlow)
{
Flow(eventToFlow);
}
}
示例2: Flow
public IEnumerable<IEvent> Flow(IEvent @event)
{
log.InfoFormat("Received {0}", @event.GetType());
log.DebugFormat("Flowing {0} to decision maker {1} to move the event forward", @event.GetType(),
decisionMaker.GetType());
return decisionMaker.MakeDecision(@event);
}
示例3: Envelope
public Envelope(IEvent message)
{
this.Headers = message.Headers;
this.Body = message.Serialize();
this.EventType = message.GetType().FullName;
if (string.IsNullOrEmpty(this.Topic)) { this.Topic = message.GetType().FullName; }
}
示例4: Flow
public IEnumerable<IEvent> Flow(IEvent @event)
{
log.InfoFormat("Received {0} in pipelet {1}", @event.GetType(), this.GetType());
if (!WantsEvent(@event))
{
log.InfoFormat("Ignoring event {0} because filter is not satisfied", @event.GetType());
return ListOfEvents.EmptyList();
}
return Accept(@event);
}
示例5: Equals
public bool Equals(IEvent toCompare)
{
if (toCompare.GetType().Equals(typeof(Unused)))
return true;
else
return false;
}
示例6: OnEvent
private void OnEvent(IEvent @event, bool isNew)
{
string eventName = "On" + @event.GetType().Name.Replace("Event", "");
MethodInfo method = GetType().GetMethod(eventName);
method.Invoke(this, new object[] { @event });
if (isNew)_uncommitedEvents.Add(@event);
}
示例7: ApplyChange
/// <summary>
/// Apply the event
/// </summary>
/// <param name="event"></param>
/// <param name="isNew"></param>
public void ApplyChange(IEvent @event, bool isNew = true)
{
var targetType = GetType();
var methodsToMatch = targetType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
var expectedName = string.Format("On{0}", @event.GetType().Name);
foreach (var method in methodsToMatch) {
if (string.Compare(method.Name, expectedName, StringComparison.OrdinalIgnoreCase) != 0)
continue;
var parameters = method.GetParameters();
if (parameters.Length != 1 || !typeof(IEvent).IsAssignableFrom(parameters[0].ParameterType))
continue;
method.Invoke(this, new[] { @event });
if (isNew)
_changes.Add(@event);
return;
}
throw new Exception(string.Format("Could not find a method named {0} on type {1}", expectedName, GetType().Name));
}
示例8: Publish
public void Publish(IEvent @event)
{
Console.WriteLine("========================================");
Console.WriteLine("Publishing event {0}", @event.GetType());
Console.WriteLine("Event {0}", @event);
Console.WriteLine("========================================");
}
示例9: EventHandler
/*============================================================================*/
/* Private Functions */
/*============================================================================*/
private void EventHandler(IEvent evt)
{
/**
* Map(CustomType, typeof(IEvent)). Dispatch(new CustomEvent(CustomType)). Make it inject IEvent
* Map(CustomType). Dispatch(new Event(CustomType)). Make it inject IEvent
* Map(CustomType). Dispatch(new CustomEvent(CustomType)). Make it inject CustomEvent
*
* Map(CustomType).typeof(CustomType) Dispatch(new Event(CustomType)). Make it not execute
*/
Type evtType = evt.GetType ();
Type payloadEvtType = null;
if (evtType == _eventClass || (_eventClass == null))
{
payloadEvtType = (evtType == typeof(Event)) ? typeof(IEvent) : evtType;
}
else if (_eventClass == typeof(IEvent))
{
payloadEvtType = _eventClass;
payloadEvtType = typeof (IEvent);
}
else
return;
_executor.ExecuteCommands(_mappings.GetList(), new CommandPayload (new List<object>{ evt }, new List<Type>{ payloadEvtType }));
}
示例10: RebuildPipeline
protected IEnumerable<IPipelet> RebuildPipeline(IEvent @event)
{
log.InfoFormat("Rebuilding pipeline for event {0}", @event.GetType());
var rebuildPipeline = pipelets.Where(p => p.WantsEvent(@event)).ToList();
return rebuildPipeline;
}
示例11: Send
public void Send(IEvent @event)
{
var eventType = @event.GetType();
var eventTypes = new List<Type>{ eventType };
var baseEventType = eventType.BaseType;
while (baseEventType != null && typeof(IEvent).IsAssignableFrom(baseEventType))
{
eventTypes.Add(baseEventType);
baseEventType = baseEventType.BaseType;
}
foreach (var @interface in eventType.GetInterfaces())
{
if (typeof(IEvent).IsAssignableFrom(@interface))
{
eventTypes.Add(@interface);
}
}
foreach (var type in eventTypes)
{
var handlers = FindDirectHandlers(type);
InvokeHandlers(@event, handlers);
}
}
示例12: SatisfiedBy
public bool SatisfiedBy(IEvent @event)
{
if (@event.GetType() != typeof (NumberOfEventsEvent))
return false;
return (@event as NumberOfEventsEvent).Number >= greaterThan && successor.SatisfiedBy(@event);
}
示例13: EventDescriptor
public EventDescriptor(IEvent eventData, EventHeader header)
: this()
{
var type = eventData.GetType();
var name = String.Format("{0},{1}", type.FullName, type.Assembly.GetName().Name);
EventData = new EventData(name, eventData);
Header = header;
}
示例14: PublishEvent
public static int Instance { get; private set; } // TODO: Re-evaluate need for static instance counter - it was added for testing IoC only
public void PublishEvent( IEvent evnt )
{
List<IEventListener> listeners;
if ( Listeners.TryGetValue( evnt.GetType(), out listeners ) )
{
listeners.ForEach( a => a.HandleEvent( evnt ) );
}
}
示例15: Accept
protected override IEnumerable<IEvent> Accept(IEvent @event)
{
log.DebugFormat("Publishing {0} to {1} publiser", @event.GetType(), publisher.GetType());
publisher.Publish(@event);
return ListOfEvents.EmptyList();
}