CSLA.NET 6.0.0
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.Core.IUseApplicationContext Csla.Serialization.Mobile.IMobileObject

Classes

class  RunRulesResult
 

Public Member Functions

 BusinessRules ()
 Creates an instance of the type. More...
 
 BusinessRules (ApplicationContext applicationContext, IHostRules target)
 Creates an instance of the type. More...
 
string[] GetRuleDescriptions ()
 Gets a list of rule:// URI values for the rules defined in 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 (ApplicationContext applicationContext, AuthorizationActions action, Csla.Core.IMemberInfo element)
 Checks per-property authorization rules. More...
 
bool CachePermissionResult (AuthorizationActions action, 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 void AddRule (ApplicationContext applicationContext, Type objectType, IAuthorizationRule rule, string ruleSet)
 Associates a per-type authorization rule with the business type. More...
 
static bool HasPermission (ApplicationContext applicationContext, AuthorizationActions action, Type objectType)
 Checks per-type authorization rules. More...
 
static bool HasPermission (ApplicationContext applicationContext, AuthorizationActions action, Type objectType, object[] criteria)
 Checks per-type authorization rules. More...
 
static bool HasPermission (ApplicationContext applicationContext, AuthorizationActions action, Type objectType, string ruleSet)
 Checks per-type authorization rules. More...
 
static bool HasPermission (ApplicationContext applicationContext, AuthorizationActions action, object obj)
 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...
 
- Properties inherited from Csla.Core.IUseApplicationContext
ApplicationContext ApplicationContext [getset]
 Gets or sets the current ApplicationContext object. More...
 

Detailed Description

Tracks the business rules for a business object.

Definition at line 24 of file BusinessRules.cs.

Constructor & Destructor Documentation

◆ BusinessRules() [1/2]

Csla.Rules.BusinessRules.BusinessRules ( )

Creates an instance of the type.

Definition at line 30 of file BusinessRules.cs.

◆ BusinessRules() [2/2]

Csla.Rules.BusinessRules.BusinessRules ( ApplicationContext  applicationContext,
IHostRules  target 
)

Creates an instance of the type.

Parameters
applicationContext
targetTarget business object.

Definition at line 38 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 913 of file BusinessRules.cs.

◆ AddRule() [1/6]

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

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

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

Definition at line 231 of file BusinessRules.cs.

◆ AddRule() [2/6]

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

Associates an authorization rule with the business object.

Parameters
ruleRule object.

Definition at line 194 of file BusinessRules.cs.

◆ AddRule() [3/6]

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

Associates a business rule with the business object.

Parameters
ruleRule object.

Definition at line 174 of file BusinessRules.cs.

◆ AddRule() [4/6]

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 184 of file BusinessRules.cs.

◆ AddRule() [5/6]

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 206 of file BusinessRules.cs.

◆ AddRule() [6/6]

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 218 of file BusinessRules.cs.

◆ CachePermissionResult()

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

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

Parameters
actionAuthorization action.
elementProperty or method to check.

Definition at line 435 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 519 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 492 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 587 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 479 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 458 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 1062 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 1072 of file BusinessRules.cs.

◆ GetBrokenRules()

BrokenRulesCollection Csla.Rules.BusinessRules.GetBrokenRules ( )

Gets the broken rules list.

Definition at line 262 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 316 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 148 of file BusinessRules.cs.

◆ HasPermission() [1/5]

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

Checks per-property authorization rules.

Parameters
applicationContext
actionAuthorization action.
elementProperty or method to check.

Definition at line 406 of file BusinessRules.cs.

◆ HasPermission() [2/5]

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

Checks per-instance authorization rules.

Parameters
applicationContext
actionAuthorization action.
objBusiness object instance.

Definition at line 373 of file BusinessRules.cs.

◆ HasPermission() [3/5]

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

Checks per-type authorization rules.

Parameters
applicationContext
actionAuthorization action.
objectTypeType of business object.

Definition at line 327 of file BusinessRules.cs.

◆ HasPermission() [4/5]

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

Checks per-type authorization rules.

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

Definition at line 342 of file BusinessRules.cs.

◆ HasPermission() [5/5]

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

Checks per-type authorization rules.

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

Definition at line 360 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 1006 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 969 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 1028 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 987 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 112 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 254 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 80 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 91 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 298 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 273 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 69 of file BusinessRules.cs.