2using System.Collections.Generic;
5using System.Threading.Tasks;
53 internal static PropertyInfo<int> ValueAaProperty = RegisterProperty<int>(c => c.ValueAa);
56 get {
return GetProperty(ValueAaProperty); }
57 set { SetProperty(ValueAaProperty, value); }
60 internal static PropertyInfo<int> ValueAbProperty = RegisterProperty<int>(c => c.ValueAb);
63 get {
return GetProperty(ValueAbProperty); }
64 set { SetProperty(ValueAbProperty, value); }
67 internal static PropertyInfo<int> ValueAcProperty = RegisterProperty<int>(c => c.ValueAc);
70 get {
return GetProperty(ValueAcProperty); }
71 set { SetProperty(ValueAcProperty, value); }
74 internal static PropertyInfo<int> ValueAdProperty = RegisterProperty<int>(c => c.ValueAd);
77 get {
return GetProperty(ValueAdProperty); }
78 set { SetProperty(ValueAdProperty, value); }
81 internal static PropertyInfo<int> ValueAeProperty = RegisterProperty<int>(c => c.ValueAe);
84 get {
return GetProperty(ValueAeProperty); }
85 set { SetProperty(ValueAeProperty, value); }
88 internal static PropertyInfo<int> ValueAfProperty = RegisterProperty<int>(c => c.ValueAf);
91 get {
return GetProperty(ValueAfProperty); }
92 set { SetProperty(ValueAfProperty, value); }
95 internal static PropertyInfo<int> ValueAgProperty = RegisterProperty<int>(c => c.ValueAg);
98 get {
return GetProperty(ValueAgProperty); }
99 set { SetProperty(ValueAgProperty, value); }
102 internal static PropertyInfo<int> ValueBaProperty = RegisterProperty<int>(c => c.ValueBa);
105 get {
return GetProperty(ValueBaProperty); }
106 set { SetProperty(ValueBaProperty, value); }
109 internal static PropertyInfo<int> ValueBbProperty = RegisterProperty<int>(c => c.ValueBb);
112 get {
return GetProperty(ValueBbProperty); }
113 set { SetProperty(ValueBbProperty, value); }
119 get {
return GetProperty(ValueCaProperty); }
120 set { SetProperty(ValueCaProperty, value); }
126 get {
return GetProperty(ValueCbProperty); }
127 set { SetProperty(ValueCbProperty, value); }
133 get {
return GetProperty(ValueCcProperty); }
134 set { SetProperty(ValueCcProperty, value); }
140 get {
return GetProperty(ValueCdProperty); }
141 set { SetProperty(ValueCdProperty, value); }
147 get {
return GetProperty(ValueCeProperty); }
148 set { SetProperty(ValueCeProperty, value); }
153 base.AddBusinessRules();
187 private void Create()
195 private readonly
int _sumValue;
199 : base(value1Property)
201 _sumValue = sumValue;
202 InputProperties.Add(value1Property);
203 InputProperties.Add(value2Property);
205 _value1Property = value1Property;
206 _value2Property = value2Property;
211 protected override string GetMessage()
213 return HasMessageDelegate ? base.MessageText :
"The sum of {0} and {1} must be equal to {2}.";
218 var value1 = context.GetInputValue(_value1Property);
219 var value2 = context.GetInputValue(_value2Property);
220 if (value1 + value2 != _sumValue)
231 private readonly PropertyInfo<int> _primaryProperty;
232 private readonly PropertyInfo<int> _affectedProperty;
234 public Increment(PropertyInfo<int> primaryProperty, PropertyInfo<int> affectedProperty) : base(primaryProperty)
236 _primaryProperty = primaryProperty;
237 _affectedProperty = affectedProperty;
238 if (InputProperties ==
null)
InputProperties =
new List<IPropertyInfo>();
245 var val = context.GetInputValue(_primaryProperty);
252 private readonly PropertyInfo<int> _sourceProperty;
254 public CopyValueRule(PropertyInfo<int> targetProperty, PropertyInfo<int> sourceProperty)
255 : base(targetProperty)
258 _sourceProperty = sourceProperty;
263 var source = context.GetInputValue(_sourceProperty);
270 private readonly decimal _fraction;
274 : base(targetProperty)
278 _sourceProperty = sourceProperty;
279 _fraction = fraction;
286 var source = context.GetInputValue(_sourceProperty);
287 context.
AddOutValue(Math.Round(source * _fraction, 2, MidpointRounding.AwayFromZero));
299 : base(primaryProperty)
312 dynamic sum = context.
InputPropertyValues.Aggregate<KeyValuePair<IPropertyInfo, object>, dynamic>(0, (current, item) => current + (dynamic)item.Value);
326 : base(primaryProperty)
328 _primaryProperty = primaryProperty;
329 _affectedProperty = affectedProperty;
330 if (InputProperties ==
null) InputProperties =
new List<IPropertyInfo>();
331 InputProperties.Add(primaryProperty);
332 AffectedProperties.Add(affectedProperty);
334 this.CanRunAsAffectedProperty =
false;
339 var val = context.GetInputValue(_primaryProperty);
This is the base class from which most business objects will be derived.
Maintains metadata about a property.
virtual Csla.Core.IPropertyInfo PrimaryProperty
Gets or sets the primary property affected by this rule.
List< Csla.Core.IPropertyInfo > InputProperties
Gets a list of secondary property values to be supplied to the rule when it is executed.
List< Csla.Core.IPropertyInfo > AffectedProperties
Gets a list of properties affected by this rule.
Base class used to create business and validation rules.
Tracks the business rules for a business object.
List< string > CheckRules()
Invokes all rules for the business type.
bool CascadeOnDirtyProperties
Gets or sets a value indicating whether rule engine should cacade n-leves when property value is chan...
void AddRule(IBusinessRuleBase rule)
Associates a business rule with the business object.
Base class used to create common rules.
RuleSeverity Severity
Gets or sets the severity for this rule.
Base class for a property rule
Contains information about the result of a rule.
Parses a rule:// URI to provide easy access to the parts of the URI.
void AddQueryParameter(string key, string value)
Adds a query parameter to the URI.
override void Execute(IRuleContext context)
Business or validation rule implementation.
CalcSumRule(IPropertyInfo primaryProperty, params IPropertyInfo[] inputProperties)
Initializes a new instance of the CalcSumRule class.
override void Execute(IRuleContext context)
Business or validation rule implementation.
CalculateFractionRule(PropertyInfo< decimal > targetProperty, PropertyInfo< decimal > sourceProperty, decimal fraction)
static readonly PropertyInfo< int > Num2Property
static readonly PropertyInfo< int > Num3Property
override void AddBusinessRules()
static readonly PropertyInfo< int > Num1Property
static readonly PropertyInfo< int > Num5Property
bool CascadeOnDirtyProperties
static readonly PropertyInfo< int > Num4Property
Maintains metadata about a property.
string FriendlyName
Gets the friendly display name for the property.
Context information provided to a business rule when it is invoked.
List< RuleResult > Results
Gets a list of RuleResult objects containing the results of the rule.
void AddOutValue(object value)
Add an outbound value to update the rule's primary property on the business object once the rule is c...
Dictionary< Csla.Core.IPropertyInfo, object > InputPropertyValues
Gets a dictionary containing copies of property values from the target business object.
@ Execute
Execute operation.