CSLA.NET 5.4.2
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
Csla.Rules.BusinessRules Class Reference

Tracks the business rules for a business object. More...

Inheritance diagram for Csla.Rules.BusinessRules:
Csla.Core.MobileObject Csla.Serialization.Mobile.ISerializationNotification Csla.Rules.IBusinessRules Csla.Serialization.Mobile.IMobileObject

Classes

class  RunRulesResult
 

Public Member Functions

string[] GetRuleDescriptions ()
 Gets a list of rule:// URI values for the rules defined in the object. More...
 
 BusinessRules ()
 Creates an instance of the object. More...
 
void AddRule (IBusinessRuleBase rule)
 Associates a business rule with the business object. More...
 
void AddRule (IBusinessRuleBase rule, string ruleSet)
 Associates a business rule with the business object. More...
 
void AddRule (IAuthorizationRule rule)
 Associates an authorization rule with the business object. More...
 
BrokenRulesCollection GetBrokenRules ()
 Gets the broken rules list. More...
 
bool GetPropertyBusy (Csla.Core.IPropertyInfo property)
 Gets a value indicating whether a specific property has any async rules running. More...
 
bool HasPermission (AuthorizationActions action, Csla.Core.IMemberInfo element)
 Checks per-property authorization rules. More...
 
bool CachePermissionResult (AuthorizationActions action, Csla.Core.IMemberInfo element)
 Gets a value indicating whether the permission result can be cached. More...
 
async Task< List< string > > CheckRulesAsync (int timeout)
 Invokes all rules for the business type. More...
 
async Task< List< string > > CheckRulesAsync ()
 Invokes all rules for the business type. More...
 
List< string > CheckRules ()
 Invokes all rules for the business type. More...
 
List< string > CheckObjectRules ()
 Invokes all rules attached at the class level of the business type. More...
 
List< string > CheckRules (Csla.Core.IPropertyInfo property)
 Invokes all rules for a specific property of the business type. More...
 
void AddDataAnnotations ()
 Adds validation rules corresponding to property data annotation attributes. More...
 

Static Public Member Functions

static void AddRule (Type objectType, IAuthorizationRule rule)
 Associates a per-type authorization rule with the business type in the default rule set. More...
 
static void AddRule (Type objectType, IAuthorizationRule rule, string ruleSet)
 Associates a per-type authorization rule with the business type. More...
 
static bool HasPermission (AuthorizationActions action, Type objectType)
 Checks per-type authorization rules. More...
 
static bool HasPermission (AuthorizationActions action, Type objectType, object[] criteria)
 Checks per-type authorization rules. More...
 
static bool HasPermission (AuthorizationActions action, Type objectType, string ruleSet)
 Checks per-type authorization rules. More...
 
static bool HasPermission (AuthorizationActions action, object obj)
 Checks per-instance authorization rules. More...
 
static bool HasPermission (AuthorizationActions action, object obj, string ruleSet)
 Checks per-instance authorization rules. More...
 
static BrokenRulesTree GetAllBrokenRules (object root)
 Gets all nodes in tree that have IsValid = false (and all parents) More...
 
static BrokenRulesTree GetAllBrokenRules (object root, bool errorsOnly)
 Gets all nodes in tree that have broken rules. More...
 

Protected Member Functions

override void OnGetState (SerializationInfo info, StateMode mode)
 Override this method to insert your field values into the MobileFormatter serialzation stream. More...
 
override void OnSetState (SerializationInfo info, StateMode mode)
 Override this method to retrieve your field values from the MobileFormatter serialzation stream. More...
 
override void OnGetChildren (SerializationInfo info, MobileFormatter formatter)
 Override this method to insert your child object references into the MobileFormatter serialzation stream. More...
 
override void OnSetChildren (SerializationInfo info, MobileFormatter formatter)
 Override this method to retrieve your child object references from the MobileFormatter serialzation stream. More...
 

Properties

bool SuppressRuleChecking [getset]
 Gets or sets a value indicating whether calling CheckRules should result in rule methods being invoked. More...
 
int ProcessThroughPriority [getset]
 Gets or sets the priority through which all rules will be processed. More...
 
string?? RuleSet [getset]
 Gets or sets the rule set to use for this business object instance. More...
 
bool CascadeOnDirtyProperties [getset]
 Gets or sets a value indicating whether rule engine should cacade n-leves when property value is changed from OuputPropertyValues. More...
 
bool IsValid [get]
 Gets a value indicating whether there are any currently broken rules, which would mean the object is not valid. More...
 
bool RunningRules [get]
 Gets a value indicating whether a CheckRules operation is in progress. More...
 
bool RunningAsyncRules [getset]
 Gets a value indicating whether any async rules are currently executing. More...
 
- Properties inherited from Csla.Rules.IBusinessRules
object Target [get]
 Gets the target business object More...
 

Detailed Description

Tracks the business rules for a business object.

Definition at line 27 of file BusinessRules.cs.

Constructor & Destructor Documentation

◆ BusinessRules()

Csla.Rules.BusinessRules.BusinessRules ( )

Creates an instance of the object.

Definition at line 156 of file BusinessRules.cs.

Member Function Documentation

◆ AddDataAnnotations()

void Csla.Rules.BusinessRules.AddDataAnnotations ( )

Adds validation rules corresponding to property data annotation attributes.

Definition at line 900 of file BusinessRules.cs.

◆ AddRule() [1/5]

void Csla.Rules.BusinessRules.AddRule ( IAuthorizationRule  rule)

Associates an authorization rule with the business object.

Parameters
ruleRule object.

Definition at line 192 of file BusinessRules.cs.

◆ AddRule() [2/5]

void Csla.Rules.BusinessRules.AddRule ( IBusinessRuleBase  rule)

Associates a business rule with the business object.

Parameters
ruleRule object.

Definition at line 172 of file BusinessRules.cs.

◆ AddRule() [3/5]

void Csla.Rules.BusinessRules.AddRule ( IBusinessRuleBase  rule,
string  ruleSet 
)

Associates a business rule with the business object.

Parameters
ruleRule object.
ruleSetRule set name.

Definition at line 182 of file BusinessRules.cs.

◆ AddRule() [4/5]

static void Csla.Rules.BusinessRules.AddRule ( Type  objectType,
IAuthorizationRule  rule 
)
static

Associates a per-type authorization rule with the business type in the default rule set.

Parameters
objectTypeType of business object.
ruleRule object.

Definition at line 204 of file BusinessRules.cs.

◆ AddRule() [5/5]

static void Csla.Rules.BusinessRules.AddRule ( Type  objectType,
IAuthorizationRule  rule,
string  ruleSet 
)
static

Associates a per-type authorization rule with the business type.

Parameters
objectTypeType of business object.
ruleRule object.
ruleSetRule set name.

Definition at line 216 of file BusinessRules.cs.

◆ CachePermissionResult()

bool Csla.Rules.BusinessRules.CachePermissionResult ( AuthorizationActions  action,
Csla.Core.IMemberInfo  element 
)

Gets a value indicating whether the permission result can be cached.

Parameters
actionAuthorization action.
elementProperty or method to check.

Definition at line 423 of file BusinessRules.cs.

◆ CheckObjectRules()

List< string > Csla.Rules.BusinessRules.CheckObjectRules ( )

Invokes all rules attached at the class level of the business type.

Returns
Returns a list of property names affected by the invoked rules. The PropertyChanged event should be raised for each affected property.

Definition at line 507 of file BusinessRules.cs.

◆ CheckRules() [1/2]

List< string > Csla.Rules.BusinessRules.CheckRules ( )

Invokes all rules for the business type.

Returns
Returns a list of property names affected by the invoked rules. The PropertyChanged event should be raised for each affected property.

Definition at line 480 of file BusinessRules.cs.

◆ CheckRules() [2/2]

List< string > Csla.Rules.BusinessRules.CheckRules ( Csla.Core.IPropertyInfo  property)

Invokes all rules for a specific property of the business type.

Parameters
propertyProperty to check.
Returns
Returns a list of property names affected by the invoked rules. The PropertyChanged event should be raised for each affected property.
Exceptions
System.ArgumentNullExceptionIf property is null

Definition at line 575 of file BusinessRules.cs.

◆ CheckRulesAsync() [1/2]

async Task< List< string > > Csla.Rules.BusinessRules.CheckRulesAsync ( )

Invokes all rules for the business type.

Returns
Returns a list of property names affected by the invoked rules. The PropertyChanged event should be raised for each affected property. Does not return until all async rules are complete.

Definition at line 467 of file BusinessRules.cs.

◆ CheckRulesAsync() [2/2]

async Task< List< string > > Csla.Rules.BusinessRules.CheckRulesAsync ( int  timeout)

Invokes all rules for the business type.

Parameters
timeoutTimeout value in milliseconds
Returns
Returns a list of property names affected by the invoked rules. The PropertyChanged event should be raised for each affected property. Does not return until all async rules are complete.

Definition at line 446 of file BusinessRules.cs.

◆ GetAllBrokenRules() [1/2]

static BrokenRulesTree Csla.Rules.BusinessRules.GetAllBrokenRules ( object  root)
static

Gets all nodes in tree that have IsValid = false (and all parents)

Parameters
rootThe root.
Returns
BrukenRulesTree list

Definition at line 1049 of file BusinessRules.cs.

◆ GetAllBrokenRules() [2/2]

static BrokenRulesTree Csla.Rules.BusinessRules.GetAllBrokenRules ( object  root,
bool  errorsOnly 
)
static

Gets all nodes in tree that have broken rules.

Parameters
rootThe root.
errorsOnlyif set to true will only return objects that gave IsValid = false.
Returns

Definition at line 1059 of file BusinessRules.cs.

◆ GetBrokenRules()

BrokenRulesCollection Csla.Rules.BusinessRules.GetBrokenRules ( )

Gets the broken rules list.

Definition at line 247 of file BusinessRules.cs.

◆ GetPropertyBusy()

bool Csla.Rules.BusinessRules.GetPropertyBusy ( Csla.Core.IPropertyInfo  property)

Gets a value indicating whether a specific property has any async rules running.

Parameters
propertyProperty to check.

Definition at line 301 of file BusinessRules.cs.

◆ GetRuleDescriptions()

string[] Csla.Rules.BusinessRules.GetRuleDescriptions ( )

Gets a list of rule:// URI values for the rules defined in the object.

Returns

Definition at line 131 of file BusinessRules.cs.

◆ HasPermission() [1/6]

bool Csla.Rules.BusinessRules.HasPermission ( AuthorizationActions  action,
Csla.Core.IMemberInfo  element 
)

Checks per-property authorization rules.

Parameters
actionAuthorization action.
elementProperty or method to check.

Definition at line 394 of file BusinessRules.cs.

◆ HasPermission() [2/6]

static bool Csla.Rules.BusinessRules.HasPermission ( AuthorizationActions  action,
object  obj 
)
static

Checks per-instance authorization rules.

Parameters
actionAuthorization action.
objBusiness object instance.

Definition at line 350 of file BusinessRules.cs.

◆ HasPermission() [3/6]

static bool Csla.Rules.BusinessRules.HasPermission ( AuthorizationActions  action,
object  obj,
string  ruleSet 
)
static

Checks per-instance authorization rules.

Parameters
actionAuthorization action.
objBusiness object instance.
ruleSetThe rule set.
Returns
true if the specified action has permission; otherwise, false.

Definition at line 364 of file BusinessRules.cs.

◆ HasPermission() [4/6]

static bool Csla.Rules.BusinessRules.HasPermission ( AuthorizationActions  action,
Type  objectType 
)
static

Checks per-type authorization rules.

Parameters
actionAuthorization action.
objectTypeType of business object.

Definition at line 311 of file BusinessRules.cs.

◆ HasPermission() [5/6]

static bool Csla.Rules.BusinessRules.HasPermission ( AuthorizationActions  action,
Type  objectType,
object[]  criteria 
)
static

Checks per-type authorization rules.

Parameters
actionAuthorization action.
objectTypeType of business object.
criteriaThe criteria object provided.

Definition at line 324 of file BusinessRules.cs.

◆ HasPermission() [6/6]

static bool Csla.Rules.BusinessRules.HasPermission ( AuthorizationActions  action,
Type  objectType,
string  ruleSet 
)
static

Checks per-type authorization rules.

Parameters
actionAuthorization action.
objectTypeType of business object.
ruleSetThe rule set.
Returns
true if the specified action has permission; otherwise, false.

Definition at line 340 of file BusinessRules.cs.

◆ OnGetChildren()

override void Csla.Rules.BusinessRules.OnGetChildren ( SerializationInfo  info,
MobileFormatter  formatter 
)
protectedvirtual

Override this method to insert your child object references into the MobileFormatter serialzation stream.

Parameters
infoObject containing the data to serialize.
formatterReference to MobileFormatter instance. Use this to convert child references to/from reference id values.

Reimplemented from Csla.Core.MobileObject.

Definition at line 993 of file BusinessRules.cs.

◆ OnGetState()

override void Csla.Rules.BusinessRules.OnGetState ( SerializationInfo  info,
StateMode  mode 
)
protectedvirtual

Override this method to insert your field values into the MobileFormatter serialzation stream.

Parameters
infoObject containing the data to serialize.
modeThe StateMode indicating why this method was invoked.

Reimplemented from Csla.Core.MobileObject.

Definition at line 956 of file BusinessRules.cs.

◆ OnSetChildren()

override void Csla.Rules.BusinessRules.OnSetChildren ( SerializationInfo  info,
MobileFormatter  formatter 
)
protectedvirtual

Override this method to retrieve your child object references from the MobileFormatter serialzation stream.

Parameters
infoObject containing the data to serialize.
formatterReference to MobileFormatter instance. Use this to convert child references to/from reference id values.

Reimplemented from Csla.Core.MobileObject.

Definition at line 1015 of file BusinessRules.cs.

◆ OnSetState()

override void Csla.Rules.BusinessRules.OnSetState ( SerializationInfo  info,
StateMode  mode 
)
protectedvirtual

Override this method to retrieve your field values from the MobileFormatter serialzation stream.

Parameters
infoObject containing the data to serialize.
modeThe StateMode indicating why this method was invoked.

Reimplemented from Csla.Core.MobileObject.

Definition at line 974 of file BusinessRules.cs.

Property Documentation

◆ CascadeOnDirtyProperties

bool Csla.Rules.BusinessRules.CascadeOnDirtyProperties
getset

Gets or sets a value indicating whether rule engine should cacade n-leves when property value is changed from OuputPropertyValues.

true if [cascade when changed]; otherwise, false.

Definition at line 95 of file BusinessRules.cs.

◆ IsValid

bool Csla.Rules.BusinessRules.IsValid
get

Gets a value indicating whether there are any currently broken rules, which would mean the object is not valid.

Definition at line 239 of file BusinessRules.cs.

◆ ProcessThroughPriority

int Csla.Rules.BusinessRules.ProcessThroughPriority
getset

Gets or sets the priority through which all rules will be processed.

Definition at line 63 of file BusinessRules.cs.

◆ RuleSet

string?? Csla.Rules.BusinessRules.RuleSet
getset

Gets or sets the rule set to use for this business object instance.

Definition at line 74 of file BusinessRules.cs.

◆ RunningAsyncRules

bool Csla.Rules.BusinessRules.RunningAsyncRules
getset

Gets a value indicating whether any async rules are currently executing.

Definition at line 283 of file BusinessRules.cs.

◆ RunningRules

bool Csla.Rules.BusinessRules.RunningRules
get

Gets a value indicating whether a CheckRules operation is in progress.

Definition at line 258 of file BusinessRules.cs.

◆ SuppressRuleChecking

bool Csla.Rules.BusinessRules.SuppressRuleChecking
getset

Gets or sets a value indicating whether calling CheckRules should result in rule methods being invoked.

True to suppress all rule method invocation.

Definition at line 52 of file BusinessRules.cs.