src/Orchard.Web/Modules/Orchard.Projections/Services/PropertyShapes.cs

(开头部分) 6KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.IO;
using System.Web.Mvc;
using Orchard.ContentManagement;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.Projections.Models;
using Orchard.Tokens;
using Orchard.Utility.Extensions;

namespace Orchard.Projections.Services {
    public class PropertyShapes : IDependency {
        private readonly ITokenizer _tokenizer;

        public PropertyShapes(ITokenizer tokenizer) {
            _tokenizer = tokenizer;
            T = NullLocalizer.Instance;
        }

        public Localizer T { get; set; }

        [Shape]
        public void Properties(dynamic Display, TextWriter Output, HtmlHelper Html, IEnumerable<dynamic> Items) {
            foreach (var item in Items) {
                if((bool)item.Property.ExcludeFromDisplay) {
                    continue;
                }

                Output.WriteLine(Display(item));
            }
        }

        [Shape] 
        public void LayoutGroup(dynamic Display, TextWriter Output, HtmlHelper Html, dynamic Key, dynamic List) {
            Output.WriteLine(Display(Key)); 
            Output.WriteLine(Display(List));
        }

        [Shape]
        public void PropertyWrapper(
            dynamic Display, 
            TextWriter Output, 
            HtmlHelper Html,
            UrlHelper Url, 
            dynamic Item,
            ContentItem ContentItem,
            ContentItemMetadata ContentItemMetadata,
            PropertyRecord Property
            ) {

            // Display will encode any string which is not IHtmlString
            string resultOutput = Convert.ToString(Display(Item));
            var resultIsEmpty = String.IsNullOrEmpty(resultOutput) || (resultOutput == "0" && Property.ZeroIsEmpty);

            if(Property.HideEmpty && resultIsEmpty) {
                return;
            }

            if(Property.RewriteOutput) {
后面还有 92 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。