protected override async void Execute(Csla.Rules.IRuleContext 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(); }
protected override void Execute(Csla.Rules.IRuleContext context) { var target = (Csla.Core.BusinessBase)context.Target; if (!target.CanReadProperty(PrimaryProperty)) { context.AddInformationResult("Not allowed to read property"); } }
protected override void Execute(Csla.Rules.IRuleContext context) { var obj = (CustomerEdit)context.Target; if (obj.BrokenRulesCollection.Where(c => c.Property == PrimaryProperty.Name).Count() > 0) { context.AddInformationResult(null, true); } }
protected override void Execute(Csla.Rules.IRuleContext context) { BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (o, e) => Thread.Sleep(3000); worker.RunWorkerCompleted += (o, e) => { string val = (string)context.InputPropertyValues[PrimaryProperty]; if (val == "Error") { context.AddErrorResult("Invalid data!"); } else if (val == "Warning") { context.AddWarningResult("This might not be a great idea!"); } else if (val == "Information") { context.AddInformationResult("Just an FYI!"); } context.Complete(); }; worker.RunWorkerAsync(); }