Ejemplo n.º 1
0
        public IRule GetProcessor(RuleExpression expression)
        {
            var group      = expression as RuleExpressionGroup;
            var descriptor = expression.Descriptor as CartRuleDescriptor;

            if (group == null && descriptor == null)
            {
                throw new InvalidOperationException($"Missing cart rule descriptor for expression {expression.Id} ('{expression.RawValue.EmptyNull()}').");
            }

            IRule instance;

            if (group == null && descriptor.ProcessorType != typeof(CompositeRule))
            {
                instance = _componentContext.ResolveKeyed <IRule>(descriptor.ProcessorType);
            }
            else
            {
                instance = new CompositeRule(group, this);
            }

            return(instance);
        }
Ejemplo n.º 2
0
        public IRule GetProcessor(RuleExpression expression)
        {
            var descriptor = expression.Descriptor as CartRuleDescriptor;

            if (descriptor == null)
            {
                // TODO: ErrHandling
                throw new InvalidOperationException();
            }

            IRule instance;
            var   group = expression as RuleExpressionGroup;

            if (group == null && descriptor.ProcessorType != typeof(CompositeRule))
            {
                instance = _componentContext.ResolveKeyed <IRule>(descriptor.ProcessorType);
            }
            else
            {
                instance = new CompositeRule(group, this);
            }

            return(instance);
        }