forked from MarimerLLC/csla
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MarimerLLC#409 Allow async Task business rules via IBusinessRuleAsync…
… and BusinessRuleAsync
- Loading branch information
1 parent
c80cf09
commit e5c3bb9
Showing
12 changed files
with
387 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#if !NET40 && !NET45 | ||
//----------------------------------------------------------------------- | ||
// <copyright file="BusinessRuleAsync.cs" company="Marimer LLC"> | ||
// Copyright (c) Marimer LLC. All rights reserved. | ||
// Website: https://cslanet.com | ||
// </copyright> | ||
// <summary>Base class used to create business and validation</summary> | ||
//----------------------------------------------------------------------- | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Csla.Properties; | ||
|
||
namespace Csla.Rules | ||
{ | ||
/// <summary> | ||
/// Base class used to create async | ||
/// business and validation rules. | ||
/// </summary> | ||
public abstract class BusinessRuleAsync : BusinessRuleBase, IBusinessRuleAsync | ||
{ | ||
/// <summary> | ||
/// Gets a value indicating whether the rule will run | ||
/// on a background thread. | ||
/// </summary> | ||
public override bool IsAsync | ||
{ | ||
get { return true; } | ||
protected set { } | ||
} | ||
|
||
/// <summary> | ||
/// Creates an instance of the rule that applies | ||
/// to a business object as a whole. | ||
/// </summary> | ||
protected BusinessRuleAsync() | ||
: this(null) | ||
{ } | ||
|
||
/// <summary> | ||
/// Creates an instance of the rule that applies | ||
/// to a specfic property. | ||
/// </summary> | ||
/// <param name="primaryProperty">Primary property for this rule.</param> | ||
protected BusinessRuleAsync(Csla.Core.IPropertyInfo primaryProperty) | ||
: base(primaryProperty) | ||
{ } | ||
|
||
/// <summary> | ||
/// Business or validation rule implementation. | ||
/// </summary> | ||
/// <param name="context">Rule context object.</param> | ||
protected virtual Task ExecuteAsync(IRuleContext context) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
|
||
Task IBusinessRuleAsync.ExecuteAsync(IRuleContext context) | ||
{ | ||
PropertiesLocked = true; | ||
return ExecuteAsync(context); | ||
} | ||
} | ||
} | ||
#endif |
Oops, something went wrong.