Ejemplo n.º 1
0
            protected override async void Execute(Csla.Rules.RuleContext context)
            {
                MyExpensiveCommand result = null;

                if (IsAsync)
                {
                    result = await MyExpensiveCommand.DoCommandAsync();
                }
                else
                {
                    result = MyExpensiveCommand.DoCommandAsync().Result;
                }
                if (result == null)
                {
                    context.AddErrorResult("Command failed to run");
                }
                else if (result.Result)
                {
                    context.AddInformationResult(result.ResultText);
                }
                else
                {
                    context.AddErrorResult(result.ResultText);
                }
                context.Complete();
            }
Ejemplo n.º 2
0
 private static void HandleResult(Csla.Rules.RuleContext context, MyExpensiveCommand result)
 {
     if (result == null)
     {
         context.AddErrorResult("Command failed to run");
     }
     else if (result.Result)
     {
         context.AddInformationResult(result.ResultText);
     }
     else
     {
         context.AddErrorResult(result.ResultText);
     }
     context.Complete();
 }
Ejemplo n.º 3
0
            protected override void Execute(Csla.Rules.RuleContext context)
            {
                MyExpensiveCommand result = null;

                if (IsAsync)
                {
                    MyExpensiveCommand.BeginCommand((r) =>
                    {
                        result = r;
                        HandleResult(context, result);
                    });
                }
                else
                {
                    result = MyExpensiveCommand.DoCommand();
                    HandleResult(context, result);
                }
            }