private void EventHandler <TEvent>(AbstractEvent e) { //TODO event type could be - forced(has to be processed), queued(until there will be right mapping for it), weak(or so - is processed when there is processor) var commandType = _eventToCommandMap[e.GetType()]; var command = (ICommand)Activator.CreateInstance(commandType); if (command == null) { Debug.LogWarningFormat("<color=\"aqua\">" + this + " : MAPPED CLASS FOR {0} IS NOT {1}</color>", e.GetType(), typeof(ICommand)); return; } _injector.MapValue(e, e.GetType()); _injector.InjectInto(command); _injector.Unmap(e); //Debug.LogWarning("<color=\"aqua\">" + this + " Execute: " + command + "</color>"); command.Execute(); }
/// <summary> /// Handles the event and returns whether the reader reached an end-of-stream event (either the end of the whole stream or the end of an superstep). /// </summary> /// <param name="event"></param> /// <returns></returns> protected virtual bool HandleEvent(AbstractEvent @event) { var eventType = @event.GetType(); try { // ------------------------------------------------------------ // Runtime events // ------------------------------------------------------------ switch (@event) { // This event is also checked at the (single) input gate to release the respective // channel, at which it was received. case EndOfPartitionEvent _: return(true); // ------------------------------------------------------------ // Task events (user) // ------------------------------------------------------------ case EndOfSuperStepEvent _: return(IncrementEndOfSuperstepEventAndCheck()); case TaskEvent taskEvent: _taskEventBus.Publish(taskEvent); return(false); default: throw new IllegalStateException($"Received unexpected event of type {eventType} at reader."); } } catch (Exception e) { throw new IOException($"Error while handling event of type {eventType}.", e); } }