本文整理汇总了C#中Event.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Event.GetType方法的具体用法?C# Event.GetType怎么用?C# Event.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Event
的用法示例。
在下文中一共展示了Event.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHeader
/// <summary>
/// Returns an header from an InfoEvent.
/// </summary>
/// <param name="Event"></param>
/// <returns></returns>
public static short GetHeader(Event Event)
{
using (DictionaryAdapter<string, short> DA = new DictionaryAdapter<string, short>(InfoEvents))
{
return DA.TryPopValue(Event.GetType().Name);
}
}
示例2: UniqueEvent
protected UniqueEvent(Guid identity, Event @event, DateTime raisedTimestamp)
{
Identity = identity;
UntypedEvent = @event;
RaisedTimestamp = raisedTimestamp;
EventType = @event.GetType();
ConsumptionRecords = new List<ConsumptionRecord>();
}
示例3: add
public void add(Event e)
{
if (!HiddenAccessN.isCriticalEvent(e))
{
HiddenAccessN.setEventPriority(e, getEventPriority(e.GetType().Name));
}
HiddenAccessN.setEventTime(e, getTime());
addImpl(e);
}
示例4: Publish
/// <summary>
/// Publishes event to multiple or none subscribers (handlers).
/// </summary>
/// <param name="event">Event to publish.</param>
public void Publish(Event @event)
{
var type = typeof(IEventHandler<>).MakeGenericType(@event.GetType());
foreach (var handler in resolver.ResolveMultiple(type))
{
var instance = handler;
var method = instance.GetType().GetMethod(
"Handle", new[] { @event.GetType() });
if (method == null)
{
throw new ApplicationException(
"IEventHandler doesn't contain Handle method. Make sure it was not renamed.");
}
method.Invoke(instance, new object[] { @event });
}
}
示例5: Add
/// <summary>
/// Adds an event to the event queue.
/// </summary>
/// <param name="evnt">is the event to add to the event queue.</param>
public void Add(Event evnt)
{
if (!HiddenAccessN.IsCriticalEvent(evnt))
{
int priority = GetEventPriority(evnt.GetType().Name);
HiddenAccessN.SetEventPriority(evnt, priority);
}
AddImpl(evnt);
}
示例6: ApplyChange
private void ApplyChange(Event @event, bool isNew)
{
dynamic d = this;
d.Handle(Converter.ChangeTo(@event, @event.GetType()));
if (isNew)
{
_changes.Add(@event);
}
}
示例7: BroadcastEvent
public void BroadcastEvent(Event eventToBroadcast)
{
List<EventListenerContainer> eventListeners = eventListenerContainerMap[eventToBroadcast.GetType()];
if (eventListeners != null)
{
foreach (EventListenerContainer eventListener in eventListeners)
{
eventListener.EventListenerMethod.Invoke(eventListener.Instance, new object[] {eventToBroadcast} );
}
}
}
示例8: SaveEvent
private async void SaveEvent(Event @event, string streamName)
{
var eventDescriptor = new EventDescriptor(Guid.NewGuid(), @event.GetType().Name, @event);
var serializedEvent = JsonConvert.SerializeObject(new EventDescriptor[] { eventDescriptor });
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("http://localhost:2113/streams/");
var response = await client.PostAsync(streamName, new StringContent(serializedEvent, Encoding.UTF8, "application/vnd.eventstore.events+json"));
_logger.LogInformation(string.Format("Saving event {0} to stream resulted with {1}", eventDescriptor.EventType, response.StatusCode));
}
}
示例9: foreach
public ProjectorInfo[] this[Event @event]
{
get
{
var eventType = @event.GetType();
if (!projectorsForEvent.ContainsKey(eventType))
{
foreach (
var assembly in
AppDomain.CurrentDomain.GetAssemblies().Where(assembly => !projectorsForAssembly.ContainsKey(assembly)))
{
projectorsForAssembly[assembly] =
assembly
.GetTypes()
.Where(type => type.IsClass)
.Where(possibleProjector => typeof (Project).IsAssignableFrom(possibleProjector))
.ToArray();
}
projectorsForEvent[eventType] =
projectorsForAssembly
.SelectMany(_ => _.Value)
.Select(
possibleProjectorType =>
new
{
PossibleProjectorType = possibleProjectorType,
Projectors =
possibleProjectorType
.GetInterfaces()
.Where(iface => typeof (Project).IsAssignableFrom(iface))
.Where(projector => projector != typeof (Project))
.Where(projector => projector.GetGenericArguments()[0].IsAssignableFrom(eventType))
})
.Where(possibleProjectors => possibleProjectors.Projectors.Any())
.SelectMany(
possibleProjectors => possibleProjectors.Projectors,
(possibleProjectors, projector) =>
new ProjectorInfo(
projector.GetGenericArguments()[0],
(Project) Activator.CreateInstance(possibleProjectors.PossibleProjectorType)))
.ToArray();
}
return projectorsForEvent[eventType];
}
}
示例10: count
private void count(Event evnt)
{
String name = evnt.GetType().FullName;
object curr;
if (!counts.TryGetValue(name, out curr))
{
curr = 0;
}
counts[name] = ((int) curr) + 1;
}
示例11:
/// <summary>
/// Sends an asynchronous event to a machine.
/// </summary>
/// <param name="target">Target machine id</param>
/// <param name="e">Event</param>
void IRemoteCommunication.SendEvent(MachineId target, Event e)
{
Output.Print("Received sent event {0}", e.GetType());
PSharpRuntime.SendEvent(target, e);
}
示例12: registerNamedEvent
private void registerNamedEvent(Event e)
{
if (!HiddenAccessN.isCriticalEvent(e))
{
HiddenAccessN.setDefaultPriority(e);
}
Type type = e.GetType();
namedEvents.Add(type.FullName, e);
namedEvents.Add(type.Name, e);
}
示例13: registerEventNames
/// <summary>
/// Registers the full and simple class name of the specified event and sets the default
/// priority of the event class.
/// </summary>
/// <param name="evnt">an event belonging to the event class to register the class name for etc.</param>
private void registerEventNames(Event evnt)
{
if (!HiddenAccessN.IsCriticalEvent(evnt))
{
HiddenAccessN.SetDefaultPriority(evnt);
}
Type type = evnt.GetType();
eventNames.Add(type.FullName, evnt); // full name with package name
eventNames.Add(type.Name, evnt); // only the class name
}
示例14: Dispatch
/// <summary>
/// Dispatches an event for a robot.
/// </summary>
/// <remarks>
/// Too old events will not be dispatched and a critical event is always dispatched.
/// </remarks>
/// <param name="evnt">is the event to dispatch to the robot.</param>
private void Dispatch(Event evnt)
{
if (robot != null && evnt != null)
{
try
{
// skip too old events
if ((evnt.Time > Time - MAX_EVENT_STACK) || HiddenAccessN.IsCriticalEvent(evnt))
{
HiddenAccessN.Dispatch(evnt, robot, robotProxy.getStatics(), robotProxy.getGraphicsImpl());
}
}
// fnl: EventInterruptedException should go to the ProcessEvents() method
// catch (EventInterruptedException ignore)
// {
// }
catch (Exception ex)
{
if (ex is SecurityException)
{
robotProxy.punishSecurityViolation(robotProxy.getStatics().getName() + " " + ex.Message);
}
else if (ex.InnerException is SecurityException)
{
robotProxy.punishSecurityViolation(robotProxy.getStatics().getName() + " " + ex.InnerException + ": " + ex.Message);
}
else if (!(ex is AbortedException || ex is DeathException || ex is DisabledException || ex is WinException))
{
robotProxy.println("SYSTEM: Exception occurred on " + evnt.GetType().Name);
robotProxy.GetOut().WriteLine(ex.StackTrace);
}
throw;
}
}
}
示例15: RouteEventToCommand
//---------------------------------------------------------------------
// Internal
//---------------------------------------------------------------------
/**
* Event Handler
*
* @param event The <code>Event</code>
* @param commandClass The Type to construct and execute
* @param oneshot Should this command mapping be removed after execution?
*/
protected void RouteEventToCommand( Event e, Type commandClass, bool oneshot, Type originalEventClass )
{
if( !originalEventClass.IsInstanceOfType(e) )
return;
Type eventClass = e.GetType(); //Warning was object( e ).constructor
//TODO We will have to use the Unity lifetimemanager here
injector.MapValue( eventClass, e );
object command = injector.Instantiate( commandClass );
injector.Unmap( eventClass );
MethodInfo methodInfo = null;
try
{
methodInfo = commandClass.GetMethod("Execute");
}
catch( AmbiguousMatchException )
{
throw( new Exception("AmbiguousMatchException was thrown when trying to access to the Execute method") );
}
catch( ArgumentNullException )
{
throw( new Exception("ArgumentNullException was thrown when trying to access to the Execute method") );
}
methodInfo.Invoke(command,null);
if( oneshot )
{
UnmapEvent( e.Type, commandClass, originalEventClass );
}
}