src/Orchard.Web/Modules/Orchard.Projections/Providers/Layouts/ListLayout.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using Orchard.ContentManagement;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.Projections.Descriptors.Layout;
using Orchard.Projections.Models;
using Orchard.Projections.Services;
namespace Orchard.Projections.Providers.Layouts {
public class ListLayout : ILayoutProvider {
private readonly IContentManager _contentManager;
protected dynamic Shape { get; set; }
public ListLayout(IShapeFactory shapeFactory, IContentManager contentManager) {
_contentManager = contentManager;
Shape = shapeFactory;
T = NullLocalizer.Instance;
}
public Localizer T { get; set; }
public void Describe(DescribeLayoutContext describe) {
describe.For("Html", T("Html"),T("Html Layouts"))
.Element("List", T("Html List"), T("Organizes content items inside a simple list."),
DisplayLayout,
RenderLayout,
"ListLayout"
);
}
public LocalizedString DisplayLayout(LayoutContext context) {
string order = context.State.Order;
switch(order) {
case "ordered":
return T("Ordered Html List");
case "unordered":
return T("Unordered Html List");
default:
throw new ArgumentOutOfRangeException("order");
}
}
public dynamic RenderLayout(LayoutContext context, IEnumerable<LayoutComponentResult> layoutComponentResults) {
string order = context.State.Order;
string itemClass = context.State.ItemClass;
string listClass = context.State.ListClass;
string listId = context.State.ListId;
string listTag = order == "ordered" ? "ol" : "ul";
IEnumerable<dynamic> shapes;
if(context.LayoutRecord.Display == (int) LayoutRecord.Displays.Content) {
shapes = layoutComponentResults.Select(x => _contentManager.BuildDisplay(x.ContentItem, context.LayoutRecord.DisplayType));
}
else {
shapes = layoutComponentResults.Select(x => x.Properties);
}
后面还有 8 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
