CSLA .NET 10.0.0
A home for your business logic
Loading...
Searching...
No Matches
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 Csla.Serialization.Mobile.IMobileObjectMetastate

Classes

class  RunRulesResult

Public Member Functions

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

Static Public Member Functions

static void AddRule (Type objectType, IAuthorizationRuleBase rule)
 Associates a per-type authorization rule with the business type in the default rule set.
static void AddRule (Type objectType, IAuthorizationRuleBase rule, string ruleSet)
 Associates a per-type authorization rule with the business type.
static void AddRule (ApplicationContext? applicationContext, Type objectType, IAuthorizationRuleBase rule, string ruleSet)
 Associates a per-type authorization rule with the business type.
static bool HasPermission (ApplicationContext applicationContext, AuthorizationActions action, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType)
 Checks per-type authorization rules.
static bool HasPermission (ApplicationContext applicationContext, AuthorizationActions action, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType, object?[]? criteria)
 Checks per-type authorization rules.
static bool HasPermission (ApplicationContext applicationContext, AuthorizationActions action, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType, string? ruleSet)
 Checks per-type authorization rules.
static bool HasPermission (ApplicationContext applicationContext, AuthorizationActions action, object obj)
 Checks per-instance authorization rules.
static Task< bool > HasPermissionAsync (ApplicationContext applicationContext, AuthorizationActions action, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType, CancellationToken ct)
 Checks per-type authorization rules.
static Task< bool > HasPermissionAsync (ApplicationContext applicationContext, AuthorizationActions action, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType, object?[]? criteria, CancellationToken ct)
 Checks per-type authorization rules.
static Task< bool > HasPermissionAsync (ApplicationContext applicationContext, AuthorizationActions action, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType, string? ruleSet, CancellationToken ct)
 Checks per-type authorization rules.
static Task< bool > HasPermissionAsync (ApplicationContext applicationContext, AuthorizationActions action, object obj, CancellationToken ct)
 Checks per-instance authorization rules.
static BrokenRulesTree GetAllBrokenRules (object root)
 Gets all nodes in tree that have IsValid = false (and all parents).
static BrokenRulesTree GetAllBrokenRules (object root, bool errorsOnly)
 Gets all nodes in tree that have broken rules.

Protected Member Functions

override void OnGetState (SerializationInfo info, StateMode mode)
 Override this method to insert your field values into the MobileFormatter serialization stream.
override void OnSetState (SerializationInfo info, StateMode mode)
 Override this method to retrieve your field values from the MobileFormatter serialization stream.
override void OnGetChildren (SerializationInfo info, MobileFormatter formatter)
 Override this method to insert your child object references into the MobileFormatter serialization stream.
override void OnSetChildren (SerializationInfo info, MobileFormatter formatter)
 Override this method to retrieve your child object references from the MobileFormatter serialization stream.
virtual void Deserialized ()
 Invoked after the object has been deserialized to allow derived classes to perform custom post-deserialization processing.
Protected Member Functions inherited from Csla.Core.MobileObject
virtual void OnGetMetastate (BinaryWriter writer)
 Override this method to write field values directly to a binary stream for metastate serialization.
virtual void OnSetMetastate (BinaryReader reader)
 Override this method to read field values directly from a binary stream for metastate deserialization.

Properties

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

Detailed Description

Tracks the business rules for a business object.

Constructor & Destructor Documentation

◆ BusinessRules() [1/2]

Csla.Rules.BusinessRules.BusinessRules ( )
inline

Creates an instance of the type.

◆ BusinessRules() [2/2]

Csla.Rules.BusinessRules.BusinessRules ( ApplicationContext applicationContext,
IHostRules target,
IUnhandledAsyncRuleExceptionHandler unhandledAsyncRuleExceptionHandler )
inline

Creates an instance of the type.

Parameters
applicationContext
targetTarget business object.
unhandledAsyncRuleExceptionHandlerHandler for unhandled exceptions that occur during asynchronous rule execution.
Exceptions
ArgumentNullExceptionapplicationContext or target is null.

Member Function Documentation

◆ AddDataAnnotations()

void Csla.Rules.BusinessRules.AddDataAnnotations ( )
inline

Adds validation rules corresponding to property data annotation attributes.

◆ AddRule() [1/6]

void Csla.Rules.BusinessRules.AddRule ( ApplicationContext? applicationContext,
Type objectType,
IAuthorizationRuleBase rule,
string ruleSet )
inlinestatic

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

Parameters
applicationContextApplicationContext instance
objectTypeType of business object.
ruleRule object.
ruleSetRule set name.
Exceptions
ArgumentNullExceptionobjectType or rule is null.

◆ AddRule() [2/6]

void Csla.Rules.BusinessRules.AddRule ( IAuthorizationRuleBase rule)
inline

Associates an authorization rule with the business object.

Parameters
ruleRule object.
Exceptions
ArgumentNullExceptionrule is null.

◆ AddRule() [3/6]

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

Associates a business rule with the business object.

Parameters
ruleRule object.
Exceptions
ArgumentNullExceptionrule is null.

◆ AddRule() [4/6]

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

Associates a business rule with the business object.

Parameters
ruleRule object.
ruleSetRule set name.
Exceptions
ArgumentNullExceptionrule is null.

◆ AddRule() [5/6]

void Csla.Rules.BusinessRules.AddRule ( Type objectType,
IAuthorizationRuleBase rule )
inlinestatic

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

Parameters
objectTypeType of business object.
ruleRule object.
Exceptions
ArgumentNullExceptionobjectType or rule is null.

◆ AddRule() [6/6]

void Csla.Rules.BusinessRules.AddRule ( Type objectType,
IAuthorizationRuleBase rule,
string ruleSet )
inlinestatic

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

Parameters
objectTypeType of business object.
ruleRule object.
ruleSetRule set name.
Exceptions
ArgumentNullExceptionobjectType or rule is null.

◆ CachePermissionResult()

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

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

Parameters
actionAuthorization action.
elementProperty or method to check.
Exceptions
ArgumentNullExceptionelement is null.

◆ CheckObjectRules()

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

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.

◆ CheckRules() [1/2]

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

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.

◆ CheckRules() [2/2]

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

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

◆ CheckRulesAsync() [1/5]

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

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.

◆ CheckRulesAsync() [2/5]

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

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.

◆ CheckRulesAsync() [3/5]

Task< List< string > > Csla.Rules.BusinessRules.CheckRulesAsync ( IPropertyInfo property)
inline

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

◆ CheckRulesAsync() [4/5]

async Task< List< string > > Csla.Rules.BusinessRules.CheckRulesAsync ( IPropertyInfo property,
TimeSpan timeout )
inline

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

Parameters
propertyProperty to check.
timeoutTimeout to wait for the rule completion.
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

◆ CheckRulesAsync() [5/5]

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

Invokes all rules for the business type.

Parameters
timeoutTimeout value.
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.

◆ Deserialized()

virtual void Csla.Rules.BusinessRules.Deserialized ( )
inlineprotectedvirtual

Invoked after the object has been deserialized to allow derived classes to perform custom post-deserialization processing.

Override this method in a derived class to implement actions that should occur immediately after deserialization, such as initializing transient fields or validating object state. This method is called automatically during the deserialization process.

Implements Csla.Serialization.Mobile.ISerializationNotification.

◆ GetAllBrokenRules() [1/2]

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

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

Parameters
rootThe root.
Returns
BrukenRulesTree list
Exceptions
ArgumentNullExceptionroot is null.

◆ GetAllBrokenRules() [2/2]

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

Gets all nodes in tree that have broken rules.

Parameters
rootThe root.
errorsOnlyif set to true will only return objects that gave IsValid = false.
Exceptions
ArgumentNullExceptionroot is null.

◆ GetBrokenRules()

BrokenRulesCollection Csla.Rules.BusinessRules.GetBrokenRules ( )
inline

Gets the broken rules list.

◆ GetPropertyBusy()

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

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

Parameters
propertyProperty to check.
Exceptions
ArgumentNullExceptionproperty is null.

◆ GetRuleDescriptions()

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

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

◆ HasPermission() [1/5]

bool Csla.Rules.BusinessRules.HasPermission ( ApplicationContext applicationContext,
AuthorizationActions action,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType )
inlinestatic

Checks per-type authorization rules.

Parameters
applicationContext
actionAuthorization action.
objectTypeType of business object.
Exceptions
ArgumentNullExceptionapplicationContext or objectType is null.

◆ HasPermission() [2/5]

bool Csla.Rules.BusinessRules.HasPermission ( ApplicationContext applicationContext,
AuthorizationActions action,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType,
object??[] criteria )
inlinestatic

Checks per-type authorization rules.

Parameters
applicationContext
actionAuthorization action.
objectTypeType of business object.
criteriaThe criteria object provided.
Exceptions
ArgumentNullExceptionapplicationContext or objectType is null.

◆ HasPermission() [3/5]

bool Csla.Rules.BusinessRules.HasPermission ( ApplicationContext applicationContext,
AuthorizationActions action,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType,
string? ruleSet )
inlinestatic

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.
Exceptions
ArgumentNullExceptionapplicationContext or objectType is null.

◆ HasPermission() [4/5]

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

Checks per-property authorization rules.

Parameters
applicationContext
actionAuthorization action.
elementProperty or method to check.
Exceptions
ArgumentNullExceptionapplicationContext or element is null.

◆ HasPermission() [5/5]

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

Checks per-instance authorization rules.

Parameters
applicationContext
actionAuthorization action.
objBusiness object instance.
Exceptions
ArgumentNullExceptionapplicationContext or obj is null.

◆ HasPermissionAsync() [1/5]

Task< bool > Csla.Rules.BusinessRules.HasPermissionAsync ( ApplicationContext applicationContext,
AuthorizationActions action,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType,
CancellationToken ct )
inlinestatic

Checks per-type authorization rules.

Parameters
applicationContextThe application context.
actionThe authorization action.
objectTypeThe type of the business object.
ctThe cancellation token.
Returns
A task representing the asynchronous operation that returns a boolean indicating whether the permission is granted.
Exceptions
ArgumentNullExceptionapplicationContext or objectType is null.

◆ HasPermissionAsync() [2/5]

Task< bool > Csla.Rules.BusinessRules.HasPermissionAsync ( ApplicationContext applicationContext,
AuthorizationActions action,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType,
object??[] criteria,
CancellationToken ct )
inlinestatic

Checks per-type authorization rules.

Parameters
applicationContextThe application context.
actionThe authorization action.
objectTypeThe type of the business object.
criteriaThe criteria object provided.
ctThe cancellation token.
Returns
A task representing the asynchronous operation. The task result contains a boolean value indicating whether the permission is granted.
Exceptions
ArgumentNullExceptionapplicationContext or objectType is null.

◆ HasPermissionAsync() [3/5]

Task< bool > Csla.Rules.BusinessRules.HasPermissionAsync ( ApplicationContext applicationContext,
AuthorizationActions action,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType,
string? ruleSet,
CancellationToken ct )
inlinestatic

Checks per-type authorization rules.

Parameters
applicationContextThe application context.
actionAuthorization action.
objectTypeType of business object.
ruleSetThe rule set.
ctThe cancellation token.
Returns
true if the specified action has permission; otherwise, false.
Exceptions
ArgumentNullExceptionapplicationContext or objectType is null.

◆ HasPermissionAsync() [4/5]

async Task< bool > Csla.Rules.BusinessRules.HasPermissionAsync ( ApplicationContext applicationContext,
AuthorizationActions action,
IMemberInfo element,
CancellationToken ct )
inline

Checks per-property authorization rules.

Parameters
applicationContextThe application context.
actionThe authorization action.
elementThe property or method to check.
ctThe cancellation token.
Returns
A task representing the asynchronous operation. The task result contains a boolean value indicating whether the permission is granted.
Exceptions
ArgumentNullExceptionapplicationContext or element is null.

◆ HasPermissionAsync() [5/5]

Task< bool > Csla.Rules.BusinessRules.HasPermissionAsync ( ApplicationContext applicationContext,
AuthorizationActions action,
object obj,
CancellationToken ct )
inlinestatic

Checks per-instance authorization rules.

Parameters
applicationContextThe application context.
actionThe authorization action.
objThe business object instance.
ctThe cancellation token.
Exceptions
ArgumentNullExceptionapplicationContext or obj is null.

◆ OnGetChildren()

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

Override this method to insert your child object references into the MobileFormatter serialization 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.

◆ OnGetState()

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

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

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

Reimplemented from Csla.Core.MobileObject.

◆ OnSetChildren()

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

Override this method to retrieve your child object references from the MobileFormatter serialization 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.

◆ OnSetState()

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

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

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

Reimplemented from Csla.Core.MobileObject.

Property Documentation

◆ CascadeOnDirtyProperties

bool Csla.Rules.BusinessRules.CascadeOnDirtyProperties
getset

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

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

◆ 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.

◆ ProcessThroughPriority

int Csla.Rules.BusinessRules.ProcessThroughPriority
getset

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

◆ RuleSet

string Csla.Rules.BusinessRules.RuleSet
getset

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

◆ RunningAsyncRules

bool Csla.Rules.BusinessRules.RunningAsyncRules
getset

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

◆ RunningRules

bool Csla.Rules.BusinessRules.RunningRules
get

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

◆ 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.


The documentation for this class was generated from the following file: