示例#1
0
        /// <summary>
        /// Executes the inner rule from the outer rules context.
        /// Creates a chained context and if CanRunRule will execute the inner rule.
        /// </summary>
        /// <param name="innerRule">The inner rule.</param>
        public void ExecuteRule(IBusinessRuleBase innerRule)
        {
            var chainedContext = GetChainedContext(innerRule);

            if (BusinessRules.CanRunRule(ApplicationContext, innerRule, chainedContext.ExecuteContext))
            {
                if (innerRule is IBusinessRule syncRule)
                {
                    syncRule.Execute(chainedContext);
                }
                else if (innerRule is IBusinessRuleAsync asyncRule)
                {
                    asyncRule.ExecuteAsync(chainedContext).ContinueWith((t) => { chainedContext.Complete(); });
                }
                else
                {
                    throw new ArgumentOutOfRangeException(innerRule.GetType().FullName);
                }
            }
        }
示例#2
0
        private static string GetTypeName(IBusinessRuleBase rule)
        {
            var type = rule.GetType();

            return(GetTypeName(type));
        }