9using System.ComponentModel;
10using System.Collections.Generic;
13using System.Security.Principal;
14using System.Security.Claims;
55 [EditorBrowsable(EditorBrowsableState.Never)]
61 public object Target {
get;
internal set; }
76 [EditorBrowsable(EditorBrowsableState.Never)]
83 return _dirtyProperties.
Value;
92 [EditorBrowsable(EditorBrowsableState.Never)]
97 if (!_outputPropertyValues.IsValueCreated)
99 return _outputPropertyValues.Value;
107 private List<RuleResult> _results;
112 [EditorBrowsable(EditorBrowsableState.Never)]
117 if (_results ==
null)
118 _results =
new List<RuleResult>();
127 private readonly Action<IRuleContext> _completeHandler;
133 [EditorBrowsable(EditorBrowsableState.Never)]
154 syncRule.Execute(chainedContext);
156 asyncRule.ExecuteAsync(chainedContext).ContinueWith((t) => { chainedContext.Complete(); });
158 throw new ArgumentOutOfRangeException(innerRule.GetType().FullName);
168 [EditorBrowsable(EditorBrowsableState.Never)]
180 [EditorBrowsable(EditorBrowsableState.Never)]
192 [EditorBrowsable(EditorBrowsableState.Never)]
204 [EditorBrowsable(EditorBrowsableState.Never)]
212 ApplicationContext = applicationContext ??
throw new ArgumentNullException(nameof(applicationContext));
213 _completeHandler = completeHandler;
214 _outputPropertyValues =
221 : this(applicationContext, completeHandler)
226 internal RuleContext(
ApplicationContext applicationContext, Action<IRuleContext> completeHandler, LazySingleton<Dictionary<IPropertyInfo, object>> outputPropertyValues, LazySingleton<List<IPropertyInfo>> dirtyProperties,
RuleContextModes executeContext)
228 ApplicationContext = applicationContext ??
throw new ArgumentNullException(nameof(applicationContext));
230 _completeHandler = completeHandler;
231 _outputPropertyValues = outputPropertyValues;
232 _dirtyProperties = dirtyProperties;
244 : this(applicationContext, completeHandler)
414 _outputPropertyValues.Value[property] = value;
423 [EditorBrowsable(EditorBrowsableState.Never)]
428 _dirtyProperties.
Value.Add(property);
440 _completeHandler?.Invoke(
this);
Provides consistent context information between the client and server DataPortal objects.
object CreateInstanceDI(Type objectType, params object[] parameters)
Creates an object using 'Activator.CreateInstance' using service provider (if one is available) to po...
An alternative to Lazy<T>
T Value
Gets the instance.
bool IsValueCreated
Gets a value indicating whether this instance is initilized and contains a value.
A strongly-typed resource class, for looking up localized strings, etc.
static string PropertyNotInAffectedPropertiesException
Looks up a localized string similar to Property {0} must be added to AffectedProperties.
Maintains metadata about a property.
Tracks the business rules for a business object.
Context information provided to a business rule when it is invoked.
void AddWarningResult(string description)
Add a Warning severity result to the Results list.
void AddSuccessResult(bool stopProcessing)
Add a Success severity result to the Results list.
object Target
Gets a reference to the target business object.
Dictionary< Csla.Core.IPropertyInfo, object > OutputPropertyValues
Gets a dictionary containing copies of property values that should be updated in the target object.
List< IPropertyInfo > DirtyProperties
Gets a list of dirty properties (value was updated).
bool IsPropertyChangedContext
Gets a value indicating whether this instance is property changed context.
bool IsCheckObjectRulesContext
Gets a value indicating whether this instance is check object rules context.
void AddErrorResult(Csla.Core.IPropertyInfo property, string description)
Add a Error severity result to the Results list.
List< RuleResult > Results
Gets a list of RuleResult objects containing the results of the rule.
void AddWarningResult(string description, bool stopProcessing)
Add a Warning severity result to the Results list.
RuleContextModes ExecuteContext
Gets the execution context.
RuleContext(ApplicationContext applicationContext, Action< IRuleContext > completeHandler, IBusinessRuleBase rule, object target, Dictionary< Csla.Core.IPropertyInfo, object > inputPropertyValues)
Creates a RuleContext instance for unit tests.
void AddErrorResult(string description)
Add a Error severity result to the Results list.
void AddWarningResult(Csla.Core.IPropertyInfo property, string description)
Add a Warning severity result to the Results list.
void AddErrorResult(string description, bool stopProcessing)
Add a Error severity result to the Results list.
bool TryGetInputValue< T >(PropertyInfo< T > propertyInfo, ref T value)
Tries to get the value.
void ExecuteRule(IBusinessRuleBase innerRule)
Executes the inner rule from the outer rules context.
void AddOutValue(Csla.Core.IPropertyInfo property, object value)
Add an outbound value to update a property on the business object once the rule is complete.
void Complete()
Indicates that the rule processing is complete, so CSLA .NET will process the Results list.
void AddDirtyProperty(Csla.Core.IPropertyInfo property)
Adds a property name as a dirty field (changed value).
void AddInformationResult(string description, bool stopProcessing)
Add an Information severity result to the Results list.
void AddInformationResult(string description)
Add an Information severity result to the Results list.
Dictionary< Csla.Core.IPropertyInfo, object > InputPropertyValues
Gets a dictionary containing copies of property values from the target business object.
IRuleContext GetChainedContext(IBusinessRuleBase rule)
Gets a new RuleContext object for a chained rule.
string OriginPropertyName
Gets or sets the name of the origin property.
bool IsCascadeContext
Gets a value indicating whether this instance is cascade context as a result of AffectedProperties.
void AddOutValue(object value)
Add an outbound value to update the rule's primary property on the business object once the rule is c...
IBusinessRuleBase Rule
Gets the rule object.
IDataPortalFactory DataPortalFactory
Gets a data portal factory instance
bool IsCheckRulesContext
Gets a value indicating whether this instance is check rules context.
void AddInformationResult(Csla.Core.IPropertyInfo property, string description)
Add an Information severity result to the Results list.
ApplicationContext ApplicationContext
Gets a reference to the current ApplicationContext.
T GetInputValue< T >(PropertyInfo< T > propertyInfo)
Gets the value.
Contains information about the result of a rule.
string Name
Gets the member name value.
Maintains metadata about a property.
Defines a data portal service used to get an access to a client-side data portal instance.
Interface defining a business/validation rule implementation.
Interface defining a business/validation rule implementation.
bool IsAsync
Gets a value indicating whether the Execute() method will run asynchronous code.
bool ProvideTargetWhenAsync
Gets a value indicating that the Target property should be set even for an async rule (note that usin...
List< Csla.Core.IPropertyInfo > AffectedProperties
Gets a list of properties affected by this rule.
Csla.Core.IPropertyInfo PrimaryProperty
Gets the primary property affected by this rule.
string RuleName
Gets a unique rule:// URI for the specific instance of the rule within the context of the business ob...
Interface defining a business/validation rule implementation.
Context information provided to a business rule when it is invoked.
RuleContextModes
RuleContext mode flags
@ PropertyChanged
Called from PropertyHasChanged event on BO but not including cascade calls by AffectedProperties
@ CheckObjectRules
Called from CheckObjectRules
@ AsAffectedPoperty
Include cascaded calls by AffectedProperties
@ CheckRules
Called from CheckRules
@ Any
Default value, rule can run in any context