9using System.Collections.Generic;
13using System.Text.RegularExpressions;
54 public System.ComponentModel.DataAnnotations.ValidationAttribute
Attribute {
get;
private set; }
62 : base(primaryProperty)
66 if (primaryProperty !=
null)
76 var ctx =
new System.ComponentModel.DataAnnotations.ValidationContext(context.
Target, context.
ApplicationContext.CurrentServiceProvider,
null);
80 System.ComponentModel.DataAnnotations.ValidationResult result =
null;
86 result = this.
Attribute.GetValidationResult(value, ctx);
90 result = this.
Attribute.GetValidationResult(
null, ctx);
112 : base(primaryProperty)
124 : this(primaryProperty)
135 : this(primaryProperty)
156 if (value ==
null ||
string.IsNullOrWhiteSpace(value.ToString()))
172 public int Max {
get;
private set; }
180 : base(primaryProperty)
194 : this(primaryProperty, max)
206 : this(primaryProperty, max)
227 if (value !=
null && value.ToString().Length >
Max)
243 public int Min {
get;
private set; }
251 : base(primaryProperty)
265 : this(primaryProperty, min)
277 : this(primaryProperty, min)
298 if (value !=
null && value.ToString().Length <
Min)
310 where T : IComparable
315 public T
Min {
get;
private set; }
328 : base(primaryProperty)
342 : this(primaryProperty, min)
354 : this(primaryProperty, min)
380 var result = value.CompareTo(
Min);
384 if (
string.IsNullOrEmpty(
Format))
385 outValue =
Min.ToString();
398 where T : IComparable
403 public T
Max {
get;
private set; }
416 : base(primaryProperty)
430 : this(primaryProperty, max)
442 : this(primaryProperty, max)
468 var result = value.CompareTo(
Max);
472 if (
string.IsNullOrEmpty(
Format))
473 outValue =
Max.ToString();
487 #region NullResultOptions
537 : base(primaryProperty)
551 : this(primaryProperty, expression)
564 : this(primaryProperty, expression)
589 value =
string.Empty;
601 ruleSatisfied = expression.IsMatch(value.ToString());
627 get {
return _messageDelegate.Invoke(); }
631 private Func<string> _messageDelegate;
642 get {
return _messageDelegate; }
643 set { _messageDelegate = value; }
651 : base(primaryProperty)
662 : this(primaryProperty)
673 : this(primaryProperty)
708 : base(primaryProperty)
713 private void Initialize(Action<IRuleContext> rule)
716 var methodName = Rule.Method.ToString();
717 base.RuleUri.AddQueryParameter(
"r", Convert.ToBase64String(Encoding.Unicode.GetBytes(methodName)));
727 base.RuleUri.AddQueryParameter(key, value);
730 private Action<IRuleContext> Rule {
get;
set; }
759 : base(primaryProperty)
A strongly-typed resource class, for looking up localized strings, etc.
static string MaxValueRule
Looks up a localized string similar to {0} can not exceed {1}.
static string StringMaxLengthRule
Looks up a localized string similar to {0} can not exceed {1} characters.
static string StringRequiredRule
Looks up a localized string similar to {0} required.
static string MinValueRule
Looks up a localized string similar to {0} can not be less than {1}.
static string RegExMatchRule
Looks up a localized string similar to {0} does not match regular expression.
static string StringMinLengthRule
Looks up a localized string similar to {0} must be at least {1} characters.
virtual Csla.Core.IPropertyInfo PrimaryProperty
Gets or sets 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...
int Priority
Gets the rule priority.
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.
Base class used to create common rules.
CommonBusinessRule()
Creates an instance of the rule.
RuleSeverity Severity
Gets or sets the severity for this rule.
CommonBusinessRule(Csla.Core.IPropertyInfo primaryProperty)
Creates an instance of the rule.
Business rule that encapsulates a DataAnnotations ValidationAttribute rule.
override void Execute(IRuleContext context)
Rule implementation.
DataAnnotation(Csla.Core.IPropertyInfo primaryProperty, System.ComponentModel.DataAnnotations.ValidationAttribute attribute)
Creates an instance of the rule.
System.ComponentModel.DataAnnotations.ValidationAttribute Attribute
Gets the ValidationAttribute instance.
A rule that establishes a dependency between two properties.
Dependency(Csla.Core.IPropertyInfo primaryProperty, params Csla.Core.IPropertyInfo[] dependencyProperty)
Creates an instance of the rule.
Adds an information message to a property.
string MessageText
Gets the default description used by this rule.
InfoMessage(Csla.Core.IPropertyInfo primaryProperty)
Creates an instance of the rule.
override void Execute(IRuleContext context)
Rule implementation.
InfoMessage(Csla.Core.IPropertyInfo primaryProperty, string messageText)
Creates an instance of the rule.
InfoMessage(Csla.Core.IPropertyInfo primaryProperty, Func< string > messageDelegate)
Creates an instance of the rule.
Func< string > MessageDelegate
Gets or sets the localizable message function.
A business rule defined by a lambda expression.
Lambda(Action< IRuleContext > rule)
Creates an instance of the rule.
override void Execute(IRuleContext context)
Executes the rule.
Lambda(Csla.Core.IPropertyInfo primaryProperty, Action< IRuleContext > rule)
Creates an instance of the rule.
void AddQueryParameter(string key, string value)
Add a query parameter to make the RuleUri uniques for this rule and primary property.
Business rule for a maximum length string.
MaxLength(Csla.Core.IPropertyInfo primaryProperty, int max)
Creates an instance of the rule.
override void Execute(IRuleContext context)
Rule implementation.
MaxLength(Csla.Core.IPropertyInfo primaryProperty, int max, Func< string > messageDelegate)
Creates an instance of the rule.
int Max
Gets the max length value.
override string GetMessage()
Gets the error message.
MaxLength(Csla.Core.IPropertyInfo primaryProperty, int max, string message)
Creates an instance of the rule.
Business rule for a maximum value.
MaxValue(Csla.Core.IPropertyInfo primaryProperty, T max, string message)
Creates an instance of the rule.
override string GetMessage()
Gets the error message.
MaxValue(Csla.Core.IPropertyInfo primaryProperty, T max, Func< string > messageDelegate)
Creates an instance of the rule.
MaxValue(Csla.Core.IPropertyInfo primaryProperty, T max)
Creates an instance of the rule.
override void Execute(IRuleContext context)
Rule implementation.
string Format
Gets or sets the format string used to format the Max value.
Business rule for a minimum length string.
override void Execute(IRuleContext context)
Rule implementation.
override string GetMessage()
Gets the error message.
MinLength(Csla.Core.IPropertyInfo primaryProperty, int min)
Creates an instance of the rule.
MinLength(Csla.Core.IPropertyInfo primaryProperty, int min, Func< string > messageDelegate)
Creates an instance of the rule.
MinLength(Csla.Core.IPropertyInfo primaryProperty, int min, string message)
Creates an instance of the rule.
int Min
Gets the min length value.
Business rule for a minimum value.
string Format
Gets or sets the format string used to format the Min value.
MinValue(Csla.Core.IPropertyInfo primaryProperty, T min)
Creates an instance of the rule.
override void Execute(IRuleContext context)
Rule implementation.
MinValue(Csla.Core.IPropertyInfo primaryProperty, T min, Func< string > messageDelegate)
Creates an instance of the rule.
override string GetMessage()
Gets the error message.
MinValue(Csla.Core.IPropertyInfo primaryProperty, T min, string message)
Creates an instance of the rule.
Business rule that evaluates a regular expression.
RegExMatch(Csla.Core.IPropertyInfo primaryProperty, string expression)
Creates an instance of the rule.
RegExMatch(Csla.Core.IPropertyInfo primaryProperty, string expression, Func< string > messageDelegate)
Creates an instance of the rule.
NullResultOptions NullOption
Gets or sets a value that controls how null input values are handled.
override void Execute(IRuleContext context)
Rule implementation.
RegExMatch(Csla.Core.IPropertyInfo primaryProperty, string expression, string message)
Creates an instance of the rule.
override string GetMessage()
Gets the error message.
NullResultOptions
List of options for the NullResult property.
string Expression
Gets the regular expression to be evaluated.
Business rule for a required string.
override void Execute(IRuleContext context)
Rule implementation.
Required(Csla.Core.IPropertyInfo primaryProperty, Func< string > messageDelegate)
Creates an instance of the rule.
Required(Csla.Core.IPropertyInfo primaryProperty)
Creates an instance of the rule.
override string GetMessage()
Gets the error message.
Required(Csla.Core.IPropertyInfo primaryProperty, string message)
Creates an instance of the rule.
Base class for a property rule
Func< string > MessageDelegate
Gets or sets the error message function for this rule.
bool HasMessageDelegate
Gets a value indicating whether this instance has message delegate.
string MessageText
Gets or sets the error message (constant).
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.
Maintains metadata about a property.
Context information provided to a business rule when it is invoked.
object Target
Gets a reference to the target business object.
List< RuleResult > Results
Gets a list of RuleResult objects containing the results of the rule.
void AddErrorResult(string description)
Add a Error 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.
ApplicationContext ApplicationContext
Gets a reference to the current ApplicationContext.
void AddInformationResult(string description)
Add an Information severity result to the Results list.
RuleSeverity
Values for validation rule severities.