9using System.Collections.Generic;
19 private static Lazy<System.Collections.Concurrent.ConcurrentDictionary<RuleSetKey,
BusinessRuleManager>> _perTypeRules =
20 new Lazy<System.Collections.Concurrent.ConcurrentDictionary<RuleSetKey,
BusinessRuleManager>>();
24 if (ruleSet == ApplicationContext.DefaultRuleSet) ruleSet =
null;
26 var key =
new RuleSetKey { Type = type, RuleSet = ruleSet };
34 internal static void CleanupRulesForType(Type type)
39 var typeRules = _perTypeRules.Value.Where(value => value.Key.Type == type);
40 foreach (var key
in typeRules)
47 return GetRulesForType(type,
null);
50 private class RuleSetKey
52 public Type Type {
get;
set; }
53 public string RuleSet {
get;
set; }
55 public override bool Equals(
object obj)
57 if (!(obj is RuleSetKey other))
60 return this.Type.Equals(other.Type) && RuleSet == other.RuleSet;
63 public override int GetHashCode()
65 return (this.Type.FullName + RuleSet).GetHashCode();
72 public List<IBusinessRuleBase>
Rules {
get;
private set; }
82 Rules =
new List<IBusinessRuleBase>();
Manages the list of rules for a business type.
bool Initialized
Gets or sets a value indicating whether the rules have been initialized.
List< IBusinessRuleBase > Rules
Gets the list of rule objects for the business type.