Esempio n. 1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="e">Event</param>
 /// <param name="originInfo">EventOriginInfo</param>
 internal EventInfo(Event e, EventOriginInfo originInfo)
 {
     this.Event = e;
     this.EventType = e.GetType();
     this.EventName = this.EventType.FullName;
     this.OriginInfo = originInfo;
 }
Esempio n. 2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="e">Event</param>
 /// <param name="originInfo">EventOriginInfo</param>
 internal EventInfo(Event e, EventOriginInfo originInfo)
 {
     this.Event      = e;
     this.EventType  = e.GetType();
     this.EventName  = this.EventType.FullName;
     this.OriginInfo = originInfo;
 }
Esempio n. 3
0
        /// <summary>
        /// Sends an asynchronous event to a machine.
        /// </summary>
        /// <param name="sender">Sender machine</param>
        /// <param name="mid">MachineId</param>
        /// <param name="e">Event</param>
        /// <param name="isStarter">Is starting a new operation</param>
        internal virtual void Send(AbstractMachine sender, MachineId mid, Event e, bool isStarter)
        {
            EventOriginInfo originInfo = null;

            if (sender != null && sender is Machine)
            {
                originInfo = new EventOriginInfo(sender.Id,
                                                 (sender as Machine).GetType().Name,
                                                 Machine.GetQualifiedStateName((sender as Machine).CurrentState));
            }

            EventInfo eventInfo = new EventInfo(e, originInfo);

            Machine machine = null;

            if (!this.MachineMap.TryGetValue(mid.Value, out machine))
            {
                return;
            }

            bool runHandler = false;

            machine.Enqueue(eventInfo, ref runHandler);

            if (!runHandler)
            {
                return;
            }

            Task task = new Task(() =>
            {
                try
                {
                    machine.RunEventHandler();
                }
                catch (Exception)
                {
                    if (this.Configuration.ThrowInternalExceptions)
                    {
                        throw;
                    }
                }
                finally
                {
                    this.TaskMap.TryRemove(Task.CurrentId.Value, out machine);
                }
            });

            this.MachineTasks.Add(task);
            this.TaskMap.TryAdd(task.Id, machine);

            task.Start();
        }
Esempio n. 4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="e">Event</param>
 /// <param name="originInfo">EventOriginInfo</param>
 internal EventInfo(Event e, EventOriginInfo originInfo) : this(e)
 {
     OriginInfo = originInfo;
 }
Esempio n. 5
0
 /// <summary>
 /// Construtor.
 /// </summary>
 /// <param name="e">Event</param>
 /// <param name="originInfo">EventOriginInfo</param>
 /// <param name="sendStep">int</param>
 internal EventInfo(Event e, EventOriginInfo originInfo, int sendStep)
     : this(e, originInfo)
 {
     SendStep = sendStep;
 }