当前位置: 首页>>代码示例>>C#>>正文


C# Context.ShapeIsWithinAllowedRecursionDepth方法代码示例

本文整理汇总了C#中DotLiquid.Context.ShapeIsWithinAllowedRecursionDepth方法的典型用法代码示例。如果您正苦于以下问题:C# Context.ShapeIsWithinAllowedRecursionDepth方法的具体用法?C# Context.ShapeIsWithinAllowedRecursionDepth怎么用?C# Context.ShapeIsWithinAllowedRecursionDepth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DotLiquid.Context的用法示例。


在下文中一共展示了Context.ShapeIsWithinAllowedRecursionDepth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Display

        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);
        }
开发者ID:Lombiq,项目名称:Orchard-Liquid-Markup,代码行数:32,代码来源:DisplayFilter.cs

示例2: Render

        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));
        }
开发者ID:Lombiq,项目名称:Orchard-Liquid-Markup,代码行数:18,代码来源:DisplayTag.cs


注:本文中的DotLiquid.Context.ShapeIsWithinAllowedRecursionDepth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。