コード例 #1
0
        /// <summary>
        /// Обрабатывает сообщение
        /// </summary>
        /// <param name="message">Сообщение</param>
        protected void ProcessMessage(Message message)
        {
            var actionExecutionContext = new ActionExecutionContext(this);

            var actionFactories = ServiceLocationContainer
                                  .ResolveAbsolutelyAll <IActionFactoryService>()
                                  .OrderByDescending(actf => Convert.ToInt32(actf.Priority));

            actionExecutionContext.Run();

            foreach (var actionFactory in actionFactories)
            {
                var action = actionFactory.Create(message);
                if (action == null)
                {
                    continue;
                }

                if (!AllowExecute(actionExecutionContext.State, action))
                {
                    continue;
                }

                try {
                    ExecuteAction(action, actionExecutionContext);
                }
                catch (Exception ex) {
                    OnErrorOccured(this, new ErrorEventArgs(ex));
                    actionExecutionContext.Fault();
                }
                finally {
                    GC.Collect();
                }
            }
        }
コード例 #2
0
 protected virtual void ExecuteAction(IAction action, ActionExecutionContext context)
 {
     action.Execute(context);
 }