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


C# Context.GetWorkContext方法代码示例

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


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

示例1: IncludeResource

        protected RequireSettings IncludeResource(string resourceType, string resourcePath, Context context)
        {
            var workContext = context.GetWorkContext();
            var resourceManager = workContext.Resolve<IResourceManager>();
            var pathResolver = workContext.Resolve<ITemplateItemProvidedPathResolver>();

            var renderingContext = context.GetTemplateRenderingContext();
            // If a template file is being rendered then resources paths can be used as usual from themes; if a
            // template item is rendered then relative virtual paths should be handled the same way (those reference
            // flat files).
            if (renderingContext.TemplateType == Models.TemplateType.TemplateFile ||
                (resourcePath.StartsWith("~") && pathResolver.IsRealVirtualPath(resourcePath)))
            {
                var resourceRegister = new ResourceRegister(
                    new DummyWebPage { VirtualPath = renderingContext.TemplatePath },
                    resourceManager,
                    resourceType);
                return resourceRegister.Include(resourcePath);
            }
            else
            {
                if (!resourcePath.StartsWith("//") &&
                    !resourcePath.StartsWith("http://", StringComparison.OrdinalIgnoreCase) &&
                    !resourcePath.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
                {
                    resourcePath = pathResolver.GenerateUrlFromPath(resourcePath);
                }

                return resourceManager.Include(resourceType, resourcePath, resourcePath);
            }
        }
开发者ID:Lombiq,项目名称:Orchard-Liquid-Markup,代码行数:31,代码来源:ResourceManagingTagBase.cs

示例2: 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

示例3: Render

        public override void Render(Context context, TextWriter result)
        {
            if (string.IsNullOrEmpty(_titleParameter)) return;

            context
                .GetWorkContext()
                .Resolve<IPageTitleBuilder>()
                .AddTitleParts(_titleParameter.EvaluateAsStringProducingParameter(context));
        }
开发者ID:Lombiq,项目名称:Orchard-Liquid-Markup,代码行数:9,代码来源:PageTitleTag.cs

示例4: Render

        public override void Render(Context context, TextWriter result)
        {
            var wc = context.GetWorkContext();

            var resourceManager = wc.Resolve<IResourceManager>();

            resourceManager.SetMeta(new MetaEntry
            {
                Charset = _charsetParameter.EvaluateAsStringProducingParameter(context),
                Content = _contentParameter.EvaluateAsStringProducingParameter(context),
                HttpEquiv = _httpEquivParameter.EvaluateAsStringProducingParameter(context),
                Name = _nameParameter.EvaluateAsStringProducingParameter(context)
            });
        }
开发者ID:Lombiq,项目名称:Orchard-Liquid-Markup,代码行数:14,代码来源:SetMetaTag.cs

示例5: Render

        public override void Render(Context context, TextWriter result)
        {
            var wc = context.GetWorkContext();

            var resourceManager = wc.Resolve<IResourceManager>();

            resourceManager.RegisterLink(new LinkEntry
                {
                    Condition = _conditionParameter.EvaluateAsStringProducingParameter(context),
                    Href = _hrefParameter.EvaluateAsStringProducingParameter(context),
                    Rel = _relParameter.EvaluateAsStringProducingParameter(context),
                    Title = _titleParameter.EvaluateAsStringProducingParameter(context),
                    Type = _typeParameter.EvaluateAsStringProducingParameter(context)
                });
        }
开发者ID:Lombiq,项目名称:Orchard-Liquid-Markup,代码行数:15,代码来源:RegisterLinkTag.cs

示例6: 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

示例7: Render

        public override void Render(Context context, TextWriter result)
        {
            if (string.IsNullOrEmpty(_resourceReferenceParameter)) return;

            var resourceManager = context.GetWorkContext().Resolve<IResourceManager>();

            var evaluatedResourceReferenceParameter = _resourceReferenceParameter.EvaluateAsStringProducingParameter(context);
            RequireSettings script;

            // _resourceReference can be a resource name or an URL.
            if (TagName.Equals("scriptrequire", StringComparison.InvariantCultureIgnoreCase))
            {
                script = RequireResource("script", evaluatedResourceReferenceParameter, context);
            }
            else
            {
                script = IncludeResource("script", evaluatedResourceReferenceParameter, context);
            }

            script.Location = _location;
        }
开发者ID:Lombiq,项目名称:Orchard-Liquid-Markup,代码行数:21,代码来源:ScriptTag.cs

示例8: Render

        public override void Render(Context context, TextWriter result)
        {
            if (_parameters == null || !_parameters.Any()) return;

            context.GetWorkContext().Resolve<IPageClassBuilder>().AddClassNames(GetEvaluatedParameters(context));
        }
开发者ID:Lombiq,项目名称:Orchard-Liquid-Markup,代码行数:6,代码来源:AddPageClassNamesTag.cs

示例9: RequireResource

 protected RequireSettings RequireResource(string resourceType, string resourceName, Context context)
 {
     return context.GetWorkContext().Resolve<IResourceManager>().Require(resourceType, resourceName);
 }
开发者ID:Lombiq,项目名称:Orchard-Liquid-Markup,代码行数:4,代码来源:ResourceManagingTagBase.cs


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