public static string Display(Context context, dynamic input) { if (input == null || !(input is StaticShape)) return string.Empty; StaticShape shape = input; var wc = context.GetWorkContext(); // Checking if the shape is displayed multiple times. If yes it can be legitimate (although rare) but // can also indicate unwanted recursion, so capping it. if (shape.Shape.DisplayedCount == null) shape.Shape.DisplayedCount = 0; if (shape.Shape.DisplayedCount >= Constants.MaxAllowedShapeDisplayCount) { wc.LogSecurityNotificationWithContext(typeof(DisplayFilter), "Too many displays of the same shape prevented."); return string.Empty; } shape.Shape.DisplayedCount++; if (!context.ShapeIsWithinAllowedRecursionDepth(shape.Metadata.Type)) { wc.LogSecurityNotificationWithContext(typeof(DisplayFilter), "Too many recursive shape displays prevented."); return string.Empty; } context.AddCurrentShapeAsParentToShape((IShape)shape.Shape); return wc.Resolve<IShapeDisplay>().Display(shape.Shape); }
public override void Render(Context context, TextWriter result) { if (string.IsNullOrEmpty(_shapeType)) return; var wc = context.GetWorkContext(); if (!context.ShapeIsWithinAllowedRecursionDepth(_shapeType)) { wc.LogSecurityNotificationWithContext(typeof(DisplayTag), "Too many recursive shape displays prevented."); return; } var argumentsDictionary = _arguments.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.EvaluateAsParameter(context)); var shape = wc.Resolve<IShapeFactory>().Create(_shapeType, Arguments.From(argumentsDictionary)); context.AddCurrentShapeAsParentToShape(shape); result.Write(wc.Resolve<IShapeDisplay>().Display(shape)); }