public override bool Evaluate(IEvaluationContext context)
        {
            var result = false;

            if (Children.IsNullOrEmpty() && AvailableChildren.IsNullOrEmpty())
            {
                return(true);
            }

            if (Children != null && Children.Any())
            {
                if (!Not)
                {
                    result = All ? Children.All(ch => ch.Evaluate(context)) : Children.Any(ch => ch.Evaluate(context));
                }
                else
                {
                    result = All ? !Children.All(ch => ch.Evaluate(context)) : !Children.Any(ch => ch.Evaluate(context));
                }
            }

            if (AvailableChildren != null && AvailableChildren.Any())
            {
                if (!Not)
                {
                    result = All ? AvailableChildren.All(ch => ch.Evaluate(context)) : AvailableChildren.Any(ch => ch.Evaluate(context));
                }
                else
                {
                    result = All ? !AvailableChildren.All(ch => ch.Evaluate(context)) : !AvailableChildren.Any(ch => ch.Evaluate(context));
                }
            }

            return(result);
        }
Example #2
0
        public SamplePromotionConditionAndRewardTreePrototype()
        {
            // Add sample condition to the beginning of the tree
            var blockSampleConditions = new BlockSampleCondition().WithAvailConditions(new SampleCondition());

            AvailableChildren.Insert(0, blockSampleConditions);
            Children.Insert(0, blockSampleConditions);
        }
Example #3
0
 public PriceConditionTreePrototype()
 {
     WithAvailConditions(new BlockPricingCondition()
                         .WithAvailConditions(
                             new ConditionGeoTimeZone(),
                             new ConditionGeoZipCode(),
                             new ConditionStoreSearchedPhrase(),
                             new ConditionAgeIs(),
                             new ConditionGenderIs(),
                             new ConditionGeoCity(),
                             new ConditionGeoCountry(),
                             new ConditionGeoState(),
                             new ConditionLanguageIs(),
                             new UserGroupsContainsCondition()
                             )
                         );
     Children = AvailableChildren.ToList();
 }
 public DynamicContentConditionTreePrototype()
 {
     WithAvailConditions(
         new BlockContentCondition()
         .WithAvailConditions(
             new ConditionGeoTimeZone(),
             new ConditionGeoZipCode(),
             new ConditionStoreSearchedPhrase(),
             new ConditionAgeIs(),
             new ConditionGenderIs(),
             new ConditionGeoCity(),
             new ConditionGeoCountry(),
             new ConditionGeoState(),
             new ConditionLanguageIs(),
             new UserGroupsContainsCondition(),
             new DynamicContentConditionCategoryIs(),
             new DynamicContentConditionProductIs()
             )
         );
     Children = AvailableChildren.ToList();
 }