CSLA .NET 10.0.0
A home for your business logic
Loading...
Searching...
No Matches
Csla.Rules.RuleContext Class Reference

Context information provided to a business rule when it is invoked. More...

Inheritance diagram for Csla.Rules.RuleContext:
Csla.Rules.IRuleContext

Public Member Functions

void ExecuteRule (IBusinessRuleBase innerRule)
 Executes the inner rule from the outer rules context. Creates a chained context and if CanRunRule will execute the inner rule.
Parameters
innerRuleThe inner rule.
Exceptions
ArgumentNullExceptioninnerRule is null.

 RuleContext (ApplicationContext applicationContext, Action< IRuleContext > completeHandler, IBusinessRuleBase rule, object? target, Dictionary< IPropertyInfo, object?> inputPropertyValues, RuleContextModes executeContext=RuleContextModes.PropertyChanged)
 Creates a RuleContext instance for unit tests.
IRuleContext GetChainedContext (IBusinessRuleBase rule)
 Gets a new RuleContext object for a chained rule.
Parameters
ruleChained rule that will use this new context.
The properties from the existing RuleContext will be used to create the new context, with the exception of the Rule property which is set using the supplied IBusinessRule value.
void AddErrorResult (string description)
 Add a Error severity result to the Results list.
Parameters
descriptionHuman-readable description of why the rule failed.
Exceptions
ArgumentExceptiondescription is null, string.Empty or only consists of white spaces.

void AddErrorResult (string description, bool stopProcessing)
 Add a Error severity result to the Results list.
Parameters
descriptionHuman-readable description of why the rule failed.
stopProcessingTrue if no further rules should be processed for the current property.
Exceptions
ArgumentExceptiondescription is null, string.Empty or only consists of white spaces.

void AddErrorResult (IPropertyInfo property, string description)
 Add a Error severity result to the Results list. This method is only allowed on "object" level rules to allow an object level rule to set warning result on a field.
Parameters
propertyProperty to which the result applies.
descriptionHuman-readable description of why the rule failed.
Exceptions
ArgumentNullExceptionproperty is null.
System.ArgumentOutOfRangeExceptionWhen property is not defined in AffectedProperties list.
ArgumentExceptiondescription is null, string.Empty or only consists of white spaces.

void AddWarningResult (string description)
 Add a Warning severity result to the Results list.
Parameters
descriptionHuman-readable description of why the rule failed.
Exceptions
ArgumentExceptiondescription is null, string.Empty or only consists of white spaces.

void AddWarningResult (string description, bool stopProcessing)
 Add a Warning severity result to the Results list.
Parameters
descriptionHuman-readable description of why the rule failed.
stopProcessingTrue if no further rules should be processed for the current property.
Exceptions
ArgumentExceptiondescription is null, string.Empty or only consists of white spaces.

void AddWarningResult (IPropertyInfo property, string description)
 Add a Warning severity result to the Results list. This method is only allowed on "object" level rules to allow an object level rule to set warning result on a field.
Parameters
propertyProperty to which the result applies.
descriptionHuman-readable description of why the rule failed.
Exceptions
ArgumentNullExceptionproperty is null.
System.ArgumentOutOfRangeExceptionWhen property is not defined in AffectedProperties list.
ArgumentExceptiondescription is null, string.Empty or only consists of white spaces.

void AddInformationResult (string description)
 Add an Information severity result to the Results list.
Parameters
descriptionHuman-readable description of why the rule failed.
Exceptions
ArgumentExceptiondescription is null, string.Empty or only consists of white spaces.

void AddInformationResult (string description, bool stopProcessing)
 Add an Information severity result to the Results list.
Parameters
descriptionHuman-readable description of why the rule failed.
stopProcessingTrue if no further rules should be processed for the current property.
Exceptions
ArgumentExceptiondescription is null, string.Empty or only consists of white spaces.

void AddInformationResult (IPropertyInfo property, string description)
 Add an Information severity result to the Results list. This method is only allowed on "object" level rules to allow an object level rule to set warning result on a field.
Parameters
propertyProperty to which the result applies.
descriptionHuman-readable description of why the rule failed.
Exceptions
ArgumentNullExceptionproperty is null.
System.ArgumentOutOfRangeExceptionWhen property is not defined in AffectedProperties list.
ArgumentExceptiondescription is null, string.Empty or only consists of white spaces.

void AddSuccessResult (bool stopProcessing)
 Add a Success severity result to the Results list.
Parameters
stopProcessingTrue if no further rules should be processed for the current property.

void AddOutValue (object? value)
 Add an outbound value to update the rule's primary property on the business object once the rule is complete.
Parameters
valueNew property value.
Exceptions
InvalidOperationExceptionRule.IBusinessRuleBase.PrimaryProperty is null.

void AddOutValue (IPropertyInfo property, object? value)
 Add an outbound value to update a property on the business object once the rule is complete.
Parameters
propertyProperty to update.
valueNew property value.
Exceptions
ArgumentNullExceptionproperty is null.
System.ArgumentOutOfRangeExceptionWhen property is not defined in AffectedProperties list.

void AddDirtyProperty (IPropertyInfo property)
 Adds a property name as a dirty field (changed value).
Parameters
propertyThe property.
Exceptions
ArgumentNullExceptionproperty is null.
System.ArgumentOutOfRangeException

void Complete ()
 Indicates that the rule processing is complete, so CSLA .NET will process the Results list. This method must be invoked on the UI thread.
T? GetInputValue<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T > (PropertyInfo< T > propertyInfo)
 Gets the value.
Template Parameters
T
Parameters
propertyInfoThe property info.
Exceptions
ArgumentNullExceptionpropertyInfo is null.

T? GetInputValue< T > (IPropertyInfo propertyInfo)
 Gets the value with explicit cast.
Template Parameters
T
Parameters
propertyInfoThe generic property info.
Exceptions
ArgumentNullExceptionpropertyInfo is null.

bool TryGetInputValue<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T > (PropertyInfo< T > propertyInfo, ref T? value)
 Tries to get the value. Use this method on LazyLoaded properties to test if value has been provided or not.
Template Parameters
T
Parameters
propertyInfoThe generic property info.
valueThe value.
Returns
true if value exists else false
Exceptions
ArgumentNullExceptionpropertyInfo is null.

bool TryGetInputValue< T > (IPropertyInfo propertyInfo, ref T? value)
 Tries to get the value with explicit cast. Use this method on LazyLoaded properties to test if value has been provided or not.
Template Parameters
T
Parameters
propertyInfoThe generic property info.
valueThe value.
Returns
true if value exists else false
Exceptions
ArgumentNullExceptionpropertyInfo is null.

Properties

IBusinessRuleBase Rule [get, set]
 Gets the rule object.
object? Target [get, set]
 Gets a reference to the target business object.
Dictionary< IPropertyInfo, object?> InputPropertyValues [get]
 Gets a dictionary containing copies of property values from the target business object.
List< IPropertyInfoDirtyProperties [get]
 Gets a list of dirty properties (value was updated).The dirty properties.
Dictionary< IPropertyInfo, object?> OutputPropertyValues [get]
 Gets a dictionary containing copies of property values that should be updated in the target object.
List< RuleResultResults [get]
 Gets a list of RuleResult objects containing the results of the rule.
string OriginPropertyName [get]
 Gets or sets the name of the origin property.The name of the origin property.
RuleContextModes ExecuteContext [get, set]
 Gets the execution context.The execution context.
bool IsCascadeContext [get]
 Gets a value indicating whether this instance is cascade context as a result of AffectedProperties.true if this instance is cascade context; otherwise, false.
bool IsPropertyChangedContext [get]
 Gets a value indicating whether this instance is property changed context.true if this instance is property changed context; otherwise, false.
bool IsCheckRulesContext [get]
 Gets a value indicating whether this instance is check rules context.true if this instance is check rules context; otherwise, false.
bool IsCheckObjectRulesContext [get]
 Gets a value indicating whether this instance is check object rules context.
ApplicationContext ApplicationContext [get]
 Gets a reference to the current ApplicationContext.
IDataPortalFactory DataPortalFactory [get]
 Gets a data portal factory instance.

Detailed Description

Context information provided to a business rule when it is invoked.

Constructor & Destructor Documentation

◆ RuleContext()

Csla.Rules.RuleContext.RuleContext ( ApplicationContext applicationContext,
Action< IRuleContext > completeHandler,
IBusinessRuleBase rule,
object? target,
Dictionary< IPropertyInfo, object?> inputPropertyValues,
RuleContextModes executeContext = RuleContextModes::PropertyChanged )
inline

Creates a RuleContext instance for unit tests.

Parameters
applicationContextCurrent ApplicationContext
completeHandlerCallback for async rule.
ruleReference to the rule object.
targetTarget business object.
inputPropertyValuesInput property values used by the rule.
executeContextThe execution context under which the rule is running.
Exceptions
ArgumentNullExceptionapplicationContext , completeHandler , rule or inputPropertyValues is null.

Member Function Documentation

◆ AddDirtyProperty()

void Csla.Rules.RuleContext.AddDirtyProperty ( IPropertyInfo property)
inline

Adds a property name as a dirty field (changed value).

Parameters
propertyThe property.
Exceptions
ArgumentNullExceptionproperty is null.
System.ArgumentOutOfRangeException

Implements Csla.Rules.IRuleContext.

◆ AddErrorResult() [1/3]

void Csla.Rules.RuleContext.AddErrorResult ( IPropertyInfo property,
string description )
inline

Add a Error severity result to the Results list. This method is only allowed on "object" level rules to allow an object level rule to set warning result on a field.

Parameters
propertyProperty to which the result applies.
descriptionHuman-readable description of why the rule failed.
Exceptions
ArgumentNullExceptionproperty is null.
System.ArgumentOutOfRangeExceptionWhen property is not defined in AffectedProperties list.
ArgumentExceptiondescription is null, string.Empty or only consists of white spaces.

Implements Csla.Rules.IRuleContext.

◆ AddErrorResult() [2/3]

void Csla.Rules.RuleContext.AddErrorResult ( string description)
inline

Add a Error severity result to the Results list.

Parameters
descriptionHuman-readable description of why the rule failed.
Exceptions
ArgumentExceptiondescription is null, string.Empty or only consists of white spaces.

Implements Csla.Rules.IRuleContext.

◆ AddErrorResult() [3/3]

void Csla.Rules.RuleContext.AddErrorResult ( string description,
bool stopProcessing )
inline

Add a Error severity result to the Results list.

Parameters
descriptionHuman-readable description of why the rule failed.
stopProcessingTrue if no further rules should be processed for the current property.
Exceptions
ArgumentExceptiondescription is null, string.Empty or only consists of white spaces.

Implements Csla.Rules.IRuleContext.

◆ AddInformationResult() [1/3]

void Csla.Rules.RuleContext.AddInformationResult ( IPropertyInfo property,
string description )
inline

Add an Information severity result to the Results list. This method is only allowed on "object" level rules to allow an object level rule to set warning result on a field.

Parameters
propertyProperty to which the result applies.
descriptionHuman-readable description of why the rule failed.
Exceptions
ArgumentNullExceptionproperty is null.
System.ArgumentOutOfRangeExceptionWhen property is not defined in AffectedProperties list.
ArgumentExceptiondescription is null, string.Empty or only consists of white spaces.

Implements Csla.Rules.IRuleContext.

◆ AddInformationResult() [2/3]

void Csla.Rules.RuleContext.AddInformationResult ( string description)
inline

Add an Information severity result to the Results list.

Parameters
descriptionHuman-readable description of why the rule failed.
Exceptions
ArgumentExceptiondescription is null, string.Empty or only consists of white spaces.

Implements Csla.Rules.IRuleContext.

◆ AddInformationResult() [3/3]

void Csla.Rules.RuleContext.AddInformationResult ( string description,
bool stopProcessing )
inline

Add an Information severity result to the Results list.

Parameters
descriptionHuman-readable description of why the rule failed.
stopProcessingTrue if no further rules should be processed for the current property.
Exceptions
ArgumentExceptiondescription is null, string.Empty or only consists of white spaces.

Implements Csla.Rules.IRuleContext.

◆ AddOutValue() [1/2]

void Csla.Rules.RuleContext.AddOutValue ( IPropertyInfo property,
object? value )
inline

Add an outbound value to update a property on the business object once the rule is complete.

Parameters
propertyProperty to update.
valueNew property value.
Exceptions
ArgumentNullExceptionproperty is null.
System.ArgumentOutOfRangeExceptionWhen property is not defined in AffectedProperties list.

Implements Csla.Rules.IRuleContext.

◆ AddOutValue() [2/2]

void Csla.Rules.RuleContext.AddOutValue ( object? value)
inline

Add an outbound value to update the rule's primary property on the business object once the rule is complete.

Parameters
valueNew property value.
Exceptions
InvalidOperationExceptionRule.IBusinessRuleBase.PrimaryProperty is null.

Implements Csla.Rules.IRuleContext.

◆ AddSuccessResult()

void Csla.Rules.RuleContext.AddSuccessResult ( bool stopProcessing)
inline

Add a Success severity result to the Results list.

Parameters
stopProcessingTrue if no further rules should be processed for the current property.

Implements Csla.Rules.IRuleContext.

◆ AddWarningResult() [1/3]

void Csla.Rules.RuleContext.AddWarningResult ( IPropertyInfo property,
string description )
inline

Add a Warning severity result to the Results list. This method is only allowed on "object" level rules to allow an object level rule to set warning result on a field.

Parameters
propertyProperty to which the result applies.
descriptionHuman-readable description of why the rule failed.
Exceptions
ArgumentNullExceptionproperty is null.
System.ArgumentOutOfRangeExceptionWhen property is not defined in AffectedProperties list.
ArgumentExceptiondescription is null, string.Empty or only consists of white spaces.

Implements Csla.Rules.IRuleContext.

◆ AddWarningResult() [2/3]

void Csla.Rules.RuleContext.AddWarningResult ( string description)
inline

Add a Warning severity result to the Results list.

Parameters
descriptionHuman-readable description of why the rule failed.
Exceptions
ArgumentExceptiondescription is null, string.Empty or only consists of white spaces.

Implements Csla.Rules.IRuleContext.

◆ AddWarningResult() [3/3]

void Csla.Rules.RuleContext.AddWarningResult ( string description,
bool stopProcessing )
inline

Add a Warning severity result to the Results list.

Parameters
descriptionHuman-readable description of why the rule failed.
stopProcessingTrue if no further rules should be processed for the current property.
Exceptions
ArgumentExceptiondescription is null, string.Empty or only consists of white spaces.

Implements Csla.Rules.IRuleContext.

◆ Complete()

void Csla.Rules.RuleContext.Complete ( )
inline

Indicates that the rule processing is complete, so CSLA .NET will process the Results list. This method must be invoked on the UI thread.

Implements Csla.Rules.IRuleContext.

◆ ExecuteRule()

void Csla.Rules.RuleContext.ExecuteRule ( IBusinessRuleBase innerRule)
inline

Executes the inner rule from the outer rules context. Creates a chained context and if CanRunRule will execute the inner rule.

Parameters
innerRuleThe inner rule.
Exceptions
ArgumentNullExceptioninnerRule is null.

Implements Csla.Rules.IRuleContext.

◆ GetChainedContext()

IRuleContext Csla.Rules.RuleContext.GetChainedContext ( IBusinessRuleBase rule)
inline

Gets a new RuleContext object for a chained rule.

Parameters
ruleChained rule that will use this new context.
The properties from the existing RuleContext will be used to create the new context, with the exception of the Rule property which is set using the supplied IBusinessRule value.

Implements Csla.Rules.IRuleContext.

◆ GetInputValue< T >()

T? Csla.Rules.RuleContext.GetInputValue< T > ( IPropertyInfo propertyInfo)
inline

Gets the value with explicit cast.

Template Parameters
T
Parameters
propertyInfoThe generic property info.
Exceptions
ArgumentNullExceptionpropertyInfo is null.

Implements Csla.Rules.IRuleContext.

◆ GetInputValue<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T >()

T? Csla.Rules.RuleContext.GetInputValue<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T > ( PropertyInfo< T > propertyInfo)
inline

Gets the value.

Template Parameters
T
Parameters
propertyInfoThe property info.
Exceptions
ArgumentNullExceptionpropertyInfo is null.

Implements Csla.Rules.IRuleContext.

◆ TryGetInputValue< T >()

bool Csla.Rules.RuleContext.TryGetInputValue< T > ( IPropertyInfo propertyInfo,
ref T? value )
inline

Tries to get the value with explicit cast. Use this method on LazyLoaded properties to test if value has been provided or not.

Template Parameters
T
Parameters
propertyInfoThe generic property info.
valueThe value.
Returns
true if value exists else false
Exceptions
ArgumentNullExceptionpropertyInfo is null.

Implements Csla.Rules.IRuleContext.

◆ TryGetInputValue<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T >()

bool Csla.Rules.RuleContext.TryGetInputValue<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T > ( PropertyInfo< T > propertyInfo,
ref T? value )
inline

Tries to get the value. Use this method on LazyLoaded properties to test if value has been provided or not.

Template Parameters
T
Parameters
propertyInfoThe generic property info.
valueThe value.
Returns
true if value exists else false
Exceptions
ArgumentNullExceptionpropertyInfo is null.

Implements Csla.Rules.IRuleContext.

Property Documentation

◆ ApplicationContext

ApplicationContext Csla.Rules.RuleContext.ApplicationContext
get

Gets a reference to the current ApplicationContext.

Implements Csla.Rules.IRuleContext.

◆ DataPortalFactory

IDataPortalFactory Csla.Rules.RuleContext.DataPortalFactory
get

Gets a data portal factory instance.

Implements Csla.Rules.IRuleContext.

◆ DirtyProperties

List<IPropertyInfo> Csla.Rules.RuleContext.DirtyProperties
get

Gets a list of dirty properties (value was updated).The dirty properties.

Implements Csla.Rules.IRuleContext.

◆ ExecuteContext

RuleContextModes Csla.Rules.RuleContext.ExecuteContext
getset

Gets the execution context.The execution context.

Implements Csla.Rules.IRuleContext.

◆ InputPropertyValues

Dictionary<IPropertyInfo, object?> Csla.Rules.RuleContext.InputPropertyValues
get

Gets a dictionary containing copies of property values from the target business object.

Implements Csla.Rules.IRuleContext.

◆ IsCascadeContext

bool Csla.Rules.RuleContext.IsCascadeContext
get

Gets a value indicating whether this instance is cascade context as a result of AffectedProperties.true if this instance is cascade context; otherwise, false.

Implements Csla.Rules.IRuleContext.

◆ IsCheckObjectRulesContext

bool Csla.Rules.RuleContext.IsCheckObjectRulesContext
get

Gets a value indicating whether this instance is check object rules context.

true if this instance is check object rules context; otherwise, false.

Implements Csla.Rules.IRuleContext.

◆ IsCheckRulesContext

bool Csla.Rules.RuleContext.IsCheckRulesContext
get

Gets a value indicating whether this instance is check rules context.true if this instance is check rules context; otherwise, false.

Implements Csla.Rules.IRuleContext.

◆ IsPropertyChangedContext

bool Csla.Rules.RuleContext.IsPropertyChangedContext
get

Gets a value indicating whether this instance is property changed context.true if this instance is property changed context; otherwise, false.

Implements Csla.Rules.IRuleContext.

◆ OriginPropertyName

string Csla.Rules.RuleContext.OriginPropertyName
get

Gets or sets the name of the origin property.The name of the origin property.

Implements Csla.Rules.IRuleContext.

◆ OutputPropertyValues

Dictionary<IPropertyInfo, object?> Csla.Rules.RuleContext.OutputPropertyValues
get

Gets a dictionary containing copies of property values that should be updated in the target object.

Implements Csla.Rules.IRuleContext.

◆ Results

List<RuleResult> Csla.Rules.RuleContext.Results
get

Gets a list of RuleResult objects containing the results of the rule.

Implements Csla.Rules.IRuleContext.

◆ Rule

IBusinessRuleBase Csla.Rules.RuleContext.Rule
getset

Gets the rule object.

Implements Csla.Rules.IRuleContext.

◆ Target

object? Csla.Rules.RuleContext.Target
getset

Gets a reference to the target business object.

Implements Csla.Rules.IRuleContext.


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