Пример #1
0
        private bool InvokeClickAction()
        {
            if (_onClick != null || _onClickAction != null)
            {
                bool allowed = true;
                if (!string.IsNullOrWhiteSpace(SubmitScope))
                {
                    allowed = CurrentContext.Validate(SubmitScope);
                }
                if (allowed)
                {
                    if (_onClick != null)
                    {
                        LogManager.Logger.Clicked(Id, _onClick.Expression);
                        CurrentContext.JokeProviderInternal.OnTap();
                        _view.PlaySoundEffect(SoundEffects.Click);
                        _onClick.Execute();
                        return(true);
                    }

                    if (_onClickAction != null)
                    {
                        LogManager.Logger.Clicked(Id, _onClickAction.Expression);
                        CurrentContext.JokeProviderInternal.OnTap();
                        _view.PlaySoundEffect(SoundEffects.Click);
                        _onClickAction.Execute();
                        return(true);
                    }
                }
            }
            return(false);
        }
 public void Execute(TCommand action)
 {
     using (WithLogging())
     {
         decorateeHandler.Execute(action);
     }
 }
Пример #3
0
 private static void ExecuteActionShim <TAction>(
     IActionHandler <TAction> handler,
     TAction action
     )
     where TAction : IAction
 {
     handler.Execute(action);
 }
Пример #4
0
 public override void ExecuteState()
 {
     base.ExecuteState();
     if (!isExecuteState)
     {
         return;
     }
     if (currAction == null)
     {
         return;
     }
     currAction.Execute(GetContext, () => { });
 }
Пример #5
0
        public async Task <SettingDTO> GetSetting(string key, string conditional = null)
        {
            conditional = conditional ?? string.Empty;

            var query  = _context.Settings.AsQueryable();
            var result = await _handler.Execute(_logger, () => query.Where(s =>
                                                                           s.Key.Equals(key, StringComparison.OrdinalIgnoreCase) &&
                                                                           (s.Conditional.Equals(conditional, StringComparison.OrdinalIgnoreCase) || s.Conditional.Equals(string.Empty)))
                                                .OrderByDescending(_ => _.Conditional).FirstOrDefaultAsync());

            return(new SettingDTO
            {
                Key = result.Key,
                Value = result.Value
            });
        }
    static void Main(string[] args)
    {
        ContainerBuilder builder = new Autofac.ContainerBuilder();

        builder.RegisterAssemblyTypes(typeof(IActionHandler <>).Assembly)
        .AsClosedTypesOf(typeof(IActionHandler <>));
        IContainer     container = builder.Build();
        List <IAction> actions   = new List <IAction>();

        actions.Add(new DisplayMessageAction("Test1"));
        actions.Add(new DisplayMessageAction("Test2"));
        actions.Add(new BeepMessageAction(200, 200));
        foreach (IAction action in actions)
        {
            Type           actionHandlerType = typeof(IActionHandler <>).MakeGenericType(action.GetType());
            IActionHandler actionHandler     = (IActionHandler)container.Resolve(actionHandlerType);
            actionHandler.Execute(action);
        }
    }