本文整理汇总了C#中IEvent类的典型用法代码示例。如果您正苦于以下问题:C# IEvent类的具体用法?C# IEvent怎么用?C# IEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IEvent类属于命名空间,在下文中一共展示了IEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InvokeHandlers
private void InvokeHandlers(IEvent @event, IEnumerable<HandlerMethod> handlers)
{
foreach (var method in handlers)
{
object handler;
try
{
handler = HandlerActivator.CreateInstance(method.ReflectedType);
}
catch (Exception ex)
{
throw new EventHandlerException("Fail to activate event handler: " + method.ReflectedType + ". See inner exception for details.", ex);
}
try
{
method.Invoke(handler, @event);
}
catch (Exception ex)
{
throw new EventHandlerException("Fail to execute event handler: " + method.ReflectedType + ". See inner exception for details.", ex);
}
}
}
示例2: FireEvent
public void FireEvent(
IEvent @event)
{
string namespaceUri = @event.NamespaceUri;
string eventType = @event.Type;
for (int i = 0; i < count; i++)
{
// Check if the entry was added during this phase
if (entries[i].Locked)
continue;
string entryNamespaceUri = entries[i].NamespaceUri;
string entryEventType = entries[i].Type;
if (entryNamespaceUri != null && namespaceUri != null)
{
if (entryNamespaceUri != namespaceUri)
{
continue;
}
}
if (entryEventType != eventType)
{
continue;
}
entries[i].Listener(@event);
}
}
示例3: EmulatorQuit
public void EmulatorQuit(IEvent e)
{
foreach (var a in _gameEndedActions)
{
a.Invoke();
}
}
示例4: TryParse
/// <summary>
/// Tries to parse the given data to the target <see cref="IEvent"/>.
/// </summary>
/// <param name="eventParams">List of string-parameters to parse.</param>
/// <param name="target">Target instance to parse the data to.</param>
/// <returns><c>true</c> if the parsing was succesful, otherwise <c>false</c> is returned.</returns>
public bool TryParse(List<string> eventParams, IEvent target)
{
if (eventParams.Count < 4)
{
return false;
}
if (string.IsNullOrEmpty(eventParams[0]))
{
return false;
}
float posX, posY, posZ;
if( !float.TryParse(eventParams[1], out posX) ||
!float.TryParse(eventParams[2], out posY) ||
!float.TryParse(eventParams[3], out posZ) )
{
return false;
}
if (!target.HasProperty("EntityName") || !target.HasProperty("Target"))
{
return false;
}
UnityEngine.Vector3 targetPosition = new UnityEngine.Vector3();
targetPosition.x = posX;
targetPosition.y = posY;
targetPosition.z = posZ;
target.SetProperty("EntityName", eventParams[0]);
target.SetProperty("Target", targetPosition);
return true;
}
示例5: DefaultEvent
/// <summary>
/// Copy constructor
/// </summary>
protected DefaultEvent(IEvent ev)
: base(ev)
{
this.addAccessor = ev.AddAccessor;
this.removeAccessor = ev.RemoveAccessor;
this.invokeAccessor = ev.InvokeAccessor;
}
示例6: Publish
public void Publish(IEvent eventMessage)
{
foreach (var bus in _wrappedBuses)
{
bus.Publish(eventMessage);
}
}
示例7: SendEventToClient
/// <summary>
/// This method will handle sending an event to a client.
/// </summary>
public static void SendEventToClient(string ipAddress, int port, IEvent evnt)
{
try
{
var client = new TcpClient(ipAddress, port);
// TODO: Serialize the event into json...
string json = JsonConvert.SerializeObject(evnt);
byte[] data = System.Text.Encoding.Unicode.GetBytes(json);
// Get a client stream for reading and writing.
var stream = client.GetStream();
stream.Write(data, 0, data.Length);
Console.WriteLine("Sent: {0}", json);
// Close everything.
stream.Close();
client.Close();
}
catch (ArgumentNullException e)
{
Console.WriteLine("ArgumentNullException: {0}", e);
}
catch (SocketException e)
{
Console.WriteLine("SocketException: {0}", e);
}
}
示例8:
void IEventHelpers.RegisterSocketRead(IEvent e, BufferedSocket socket, IEventHandler protocol,
ReadFunction callback)
{
//Contract.Requires(socket != null);
Contract.Requires(protocol != null);
Contract.Requires(callback != null);
}
示例9: EventMessage
public EventMessage(IEvent source)
{
if (source == null)
throw new ArgumentNullException("source");
sourceMeta = new Dictionary<string, object>();
eventMeta = new Dictionary<string, object>();
var eventSource = source.EventSource;
while (eventSource != null) {
foreach (var meta in source.EventSource.Metadata) {
sourceMeta[meta.Key] = meta.Value;
}
eventSource = eventSource.ParentSource;
}
if (source.EventData != null) {
foreach (var pair in source.EventData) {
eventMeta[pair.Key] = pair.Value;
}
}
TimeStamp = source.TimeStamp;
}
示例10: run
public void run(IEvent e)
{
BoardMovedNotify notify = new BoardMovedNotify();
this.boardMachine.fireStateChangedNotification(notify);
LOG.Info(NAME);
this.boardMachine.consumeEvent(new BoardReadyEvent());
}
示例11: CreateEvent
public static bool CreateEvent(IEvent thisEvent)
{
if (Connect())
{
try
{
SqlCommand Command = Connection.CreateCommand();
Command.CommandType = CommandType.StoredProcedure;
Command.CommandText = "fif_event_create";
Command.Parameters.AddWithValue("name", thisEvent.Name);
Command.Parameters.AddWithValue("price", thisEvent.Price);
Command.Parameters.AddWithValue("description", thisEvent.Description);
Command.Parameters.AddWithValue("start_period", thisEvent.StartPeriod);
Command.Parameters.AddWithValue("end_period", thisEvent.EndPeriod);
Command.Parameters.AddWithValue("max_number_of_participants", thisEvent.MaxNumberOfParticipants);
Command.Parameters.Add("@activity_id", SqlDbType.Int, 0, "activity_id");
Command.Parameters["@activity_id"].Direction = ParameterDirection.Output;
Command.ExecuteNonQuery();
thisEvent.ActivityId = int.Parse(Command.Parameters["@activity_id"].Value.ToString());
Disconnect();
return true;
}
catch
{
Disconnect();
return false;
}
}
return false;
}
示例12: LoadIEvent
private void LoadIEvent()
{
if (_ievent == null)
{
if (this.ScheduleType == null)
{
Logger.LogInfo("计划任务没有定义其 type 属性");
}
Type type = Type.GetType(this.ScheduleType);
if (type == null)
{
Logger.LogInfo(string.Format("计划任务 {0} 无法被正确识别", this.ScheduleType));
}
else
{
_ievent = (IEvent)Activator.CreateInstance(type);
if (_ievent == null)
{
Logger.LogInfo(string.Format("计划任务 {0} 未能正确加载", this.ScheduleType));
}
}
}
}
示例13: EventToString
/// <summary>
/// Converts event to <c>string</c> representation.
/// </summary>
/// <param name="Event">Event to be converted to <c>string</c></param>
/// <returns>Returns resulting <c>string</c>.</returns>
public static string EventToString( IEvent Event )
{
StringBuilder builder = new StringBuilder( 200 );
builder.Append( "[Type=" );
builder.Append( Event.Type.ToString() );
if( Event.Description!=null )
{
builder.Append( "][Message=" );
builder.Append( Event.Description );
}
if( Event.Sender != null )
{
builder.Append( "][ModelID=" );
builder.Append( ((ILinkableComponent) Event.Sender).ModelID );
}
if( Event.SimulationTime != null )
{
builder.Append( "][SimTime=" );
builder.Append( CalendarConverter.ModifiedJulian2Gregorian(Event.SimulationTime.ModifiedJulianDay).ToString() );
}
builder.Append( ']' );
return( builder.ToString() );
}
示例14:
/// <summary>
/// Listen for VirtualBox events.
/// </summary>
/// <param name="aEvent">VirtualBox event</param>
void IEventListener.HandleEvent(IEvent aEvent)
{
if (aEvent.Type == VBoxEventType.VBoxEventType_OnMachineStateChanged)
{
vboxServer.UpdateServersState();
}
}
示例15: GetEventDataAsString
/// <summary>
/// Gets a string of all data properties of the passed <see cref="IEvent"/>.
/// Format-Example: Name0: Value0, ..., NameN: ValueN
/// </summary>
/// <param name="e"><see cref="IEvent"/> to create data string from.</param>
/// <returns>String representing the <see cref="IEvent"/> data.</returns>
public static string GetEventDataAsString(IEvent e)
{
string data = "";
if (e != null)
{
int i = 0;
foreach (PropertyInfo property in e.GetType().GetProperties())
{
if (GetNamesOfProperties().Contains(property.Name))
{
continue;
}
if (i > 0)
{
data += ", ";
}
data += string.Format("{0}: {1}", property.Name, property.GetValue(e, null));
i++;
}
}
return data;
}