protected virtual void Evaluate(CustomizeRenderingArgs args) { Assert.ArgumentNotNull(args, "args"); Item item = args.PageContext.Item; if (item != null) { RenderingReference renderingReference = GetRenderingReference(args.Rendering, args.Rendering.Item.Language, args.Rendering.Item.Database); GetRenderingRulesArgs getRenderingRulesArgs = new GetRenderingRulesArgs(item, renderingReference); GetRenderingRulesPipeline.Run(getRenderingRulesArgs); RuleList <ConditionalRenderingsRuleContext> ruleList = getRenderingRulesArgs.RuleList; if (ruleList != null && ruleList.Count != 0) { List <RenderingReference> references = new List <RenderingReference> { renderingReference }; ConditionalRenderingsRuleContext conditionalRenderingsRuleContext = new ConditionalRenderingsRuleContext(references, renderingReference) { Item = item }; conditionalRenderingsRuleContext.Parameters["mvc.rendering"] = args.Rendering; var matchingRule = GetMatchingRule(ruleList, conditionalRenderingsRuleContext); ApplyActions(args, conditionalRenderingsRuleContext, matchingRule); } } }
protected override void Evaluate(CustomizeRenderingArgs args) { Assert.ArgumentNotNull(args, "args"); Item item = args.PageContext.Item; if (item != null) { RenderingReference renderingReference = CustomizeRenderingProcessor.GetRenderingReference(args.Rendering, Context.Language, args.PageContext.Database); GetRenderingRulesArgs getRenderingRulesArgs = new GetRenderingRulesArgs(item, renderingReference); GetRenderingRulesPipeline.Run(getRenderingRulesArgs); RuleList <ConditionalRenderingsRuleContext> ruleList = getRenderingRulesArgs.RuleList; if (ruleList != null && ruleList.Count != 0) { List <RenderingReference> references = new List <RenderingReference> { renderingReference }; ConditionalRenderingsRuleContext conditionalRenderingsRuleContext = new ConditionalRenderingsRuleContext(references, renderingReference) { Item = item }; conditionalRenderingsRuleContext.Parameters["mvc.rendering"] = args.Rendering; RunRules(ruleList, conditionalRenderingsRuleContext); ApplyActions(args, conditionalRenderingsRuleContext); args.IsCustomized = true; } } }
protected override void Evaluate(CustomizeRenderingArgs args) { Assert.ArgumentNotNull(args, "args"); Item item = args.PageContext.Item; if (item == null) { return; } RenderingReference renderingReference = CustomizeRenderingProcessor.GetRenderingReference(args.Rendering, Context.Language, args.PageContext.Database); GetRenderingRulesArgs expr_3E = new GetRenderingRulesArgs(item, renderingReference); GetRenderingRulesPipeline.Run(expr_3E); RuleList <ConditionalRenderingsRuleContext> ruleList = expr_3E.RuleList; if (ruleList == null || ruleList.Count == 0) { return; } // after the ruleList has been retrieved AND ruleList > 0, instantiate a new personalization rulelist which has a fix to continue evaluation of conditions // even when some exceptions occur. PersonalizationRuleList <ConditionalRenderingsRuleContext> personalizationRuleList = new PersonalizationRuleList <ConditionalRenderingsRuleContext>(); foreach (var r in ruleList.Rules) { personalizationRuleList.Add(r); } ConditionalRenderingsRuleContext conditionalRenderingsRuleContext = new ConditionalRenderingsRuleContext(new List <RenderingReference> { renderingReference }, renderingReference) { Item = item }; conditionalRenderingsRuleContext.Parameters["mvc.rendering"] = args.Rendering; // runRules for the personalizationRuleList this.RunRules(personalizationRuleList, conditionalRenderingsRuleContext); this.ApplyActions(args, conditionalRenderingsRuleContext); args.IsCustomized = true; }