예제 #1
0
        /// <summary>
        /// Adds the shared global rules.
        /// </summary>
        /// <param name="rule">The rule to add.</param>
        /// <param name="entityType">The type of the entity</param>
        private static void AddShared(IRule rule, Type entityType)
        {
            lock (_addSharedRuleLock)
            {
                if (!_sharedBusinessRules.ContainsKey(entityType))
                {
                    _sharedBusinessRules.TryAdd(entityType, new RuleList());
                }

                _sharedBusinessRules[entityType].Add(rule);
            }
        }
예제 #2
0
 /// <summary>
 /// Adds the specified rule.
 /// </summary>
 /// <typeparam name="TEntity">The type of the entity.</typeparam>
 /// <param name="rule">The rule to add.</param>
 public void Add <TEntity>(IRule rule)
 {
     if (_businessRules.ContainsKey(typeof(TEntity)))
     {
         _businessRules[typeof(TEntity)].Add(rule);
     }
     else
     {
         _businessRules.TryAdd(typeof(TEntity), new RuleList {
             rule
         });
     }
 }