本文整理汇总了C#中Orchard.DisplayManagement.Descriptors.ShapeTableBuilder类的典型用法代码示例。如果您正苦于以下问题:C# ShapeTableBuilder类的具体用法?C# ShapeTableBuilder怎么用?C# ShapeTableBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ShapeTableBuilder类属于Orchard.DisplayManagement.Descriptors命名空间,在下文中一共展示了ShapeTableBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Discover
public void Discover(ShapeTableBuilder builder)
{
builder.Describe("Price")
.OnDisplaying(displaying => {
displaying.ShapeMetadata.Alternates.Add("Parts_" + displaying.ShapeMetadata.DisplayType);
});
}
示例2: Discover
public void Discover(ShapeTableBuilder builder) {
builder.Describe("Content")
.OnCreated(created => {
var content = created.Shape;
content.Child.Add(created.New.PlaceChildContent(Source: content));
})
.OnDisplaying(displaying => {
ContentItem contentItem = displaying.Shape.ContentItem;
if (contentItem != null) {
// Alternates in order of specificity.
// Display type > content type > specific content > display type for a content type > display type for specific content
// Content__[DisplayType] e.g. Content.Summary
displaying.ShapeMetadata.Alternates.Add("Content_" + displaying.ShapeMetadata.DisplayType);
// Content__[ContentType] e.g. Content-BlogPost
displaying.ShapeMetadata.Alternates.Add("Content__" + contentItem.ContentType);
// Content__[Id] e.g. Content-42
displaying.ShapeMetadata.Alternates.Add("Content__" + contentItem.Id);
// Content_[DisplayType]__[ContentType] e.g. Content-BlogPost.Summary
displaying.ShapeMetadata.Alternates.Add("Content_" + displaying.ShapeMetadata.DisplayType + "__" + contentItem.ContentType);
// Content_[DisplayType]__[Id] e.g. Content-42.Summary
displaying.ShapeMetadata.Alternates.Add("Content_" + displaying.ShapeMetadata.DisplayType + "__" + contentItem.Id);
if ( !displaying.ShapeMetadata.DisplayType.Contains("Admin") )
displaying.ShapeMetadata.Wrappers.Add("Content_ControlWrapper");
}
});
}
示例3: Discover
public void Discover(ShapeTableBuilder builder)
{
builder.Describe("HeadScripts")
.OnDisplaying(shapeDisplayingContext =>
{
if (!_imagesLoadedService.GetAutoEnable()) return;
if (!_imagesLoadedService.GetAutoEnableAdmin())
{
var request = _workContext.Value.HttpContext.Request;
if (AdminFilter.IsApplied(request.RequestContext))
{
return;
}
}
var resourceManager = _workContext.Value.Resolve<IResourceManager>();
var scripts = resourceManager.GetRequiredResources("script");
string includejs = "imagesLoaded";
var currentHighlight = scripts
.Where(l => l.Name == includejs)
.FirstOrDefault();
if (currentHighlight == null)
{
resourceManager.Require("script", includejs).AtFoot();
}
});
}
示例4: Discover
public void Discover(ShapeTableBuilder builder) {
builder.Describe("LogOn")
.OnDisplaying(displaying => {
var clientsData = _openAuthAuthenticationClients
.Select(client => _orchardOpenAuthClientProvider.GetClientData(client.ProviderName))
.Where(x => x != null)
.ToList();
var shape = displaying.Shape;
var metadata = displaying.ShapeMetadata;
shape.ClientsData = clientsData;
metadata.Type = "OpenAuthLogOn";
});
builder.Describe("Register")
.OnDisplaying(displaying => {
var clientsData = _openAuthAuthenticationClients
.Select(client => _orchardOpenAuthClientProvider.GetClientData(client.ProviderName))
.Where(x => x != null)
.ToList();
var shape = displaying.Shape;
var metadata = displaying.ShapeMetadata;
shape.ClientsData = clientsData;
metadata.Type = "OpenAuthRegister";
});
}
示例5: Discover
public void Discover(ShapeTableBuilder builder) {
builder.Describe("Media")
.OnDisplaying(displaying => {
ContentItem contentItem = displaying.Shape.ContentItem;
if (contentItem != null) {
// Alternates in order of specificity.
// Display type > content type > specific content > display type for a content type > display type for specific content
// BasicShapeTemplateHarvester.Adjust will then adjust the template name
// Media__[DisplayType] e.g. Media-Summary
displaying.ShapeMetadata.Alternates.Add("Media_" + EncodeAlternateElement(displaying.ShapeMetadata.DisplayType));
// Media__[ContentType] e.g. Media-BlogPost,
displaying.ShapeMetadata.Alternates.Add("Media__" + EncodeAlternateElement(contentItem.ContentType));
// Media__[Id] e.g. Media-42,
displaying.ShapeMetadata.Alternates.Add("Media__" + contentItem.Id);
// Media_[DisplayType]__[ContentType] e.g. Media-Image.Summary
displaying.ShapeMetadata.Alternates.Add("Media_" + displaying.ShapeMetadata.DisplayType + "__" + EncodeAlternateElement(contentItem.ContentType));
// Media_[DisplayType]__[Id] e.g. Media-42.Summary
displaying.ShapeMetadata.Alternates.Add("Media_" + displaying.ShapeMetadata.DisplayType + "__" + contentItem.Id);
}
});
}
示例6: Discover
public void Discover(ShapeTableBuilder builder) {
builder.Describe("HeadLinks")
.OnDisplaying(shapeDisplayingContext => {
string faviconUrl = _faviconService.GetFaviconUrl();
if (!string.IsNullOrWhiteSpace(faviconUrl)) {
// Get the current favicon from head
var resourceManager = _wca.GetContext().Resolve<IResourceManager>();
var links = resourceManager.GetRegisteredLinks();
var currentFavicon = links
.Where(l => l.Rel == "shortcut icon" && l.Type == "image/x-icon")
.FirstOrDefault();
// Modify if found
if (currentFavicon != default(LinkEntry)) {
currentFavicon.Href = faviconUrl;
}
else {
// Add the new one
resourceManager.RegisterLink(new LinkEntry {
Type = "image/x-icon",
Rel = "shortcut icon",
Href = faviconUrl
});
}
}
});
}
示例7: Discover
public void Discover(ShapeTableBuilder builder)
{
builder.Describe("Parts_Comments")
.OnDisplaying(shapeDisplayingContext =>
{
var settings = this.orchardServices.WorkContext.CurrentSite.As<DisqusSettingsPart>();
shapeDisplayingContext.Shape.DisqusSettings = settings;
shapeDisplayingContext.Shape.DisqusUniqueId = GetUniqueIdentifier(shapeDisplayingContext.Shape.ContentPart.ContentItem);
shapeDisplayingContext.ShapeMetadata.Wrappers.Add("CommentsWrapper");
});
builder.Describe("Parts_Comments_Count")
.OnDisplaying(shapeDisplayingContext =>
{
var settings = this.orchardServices.WorkContext.CurrentSite.As<DisqusSettingsPart>();
shapeDisplayingContext.Shape.DisqusSettings = settings;
shapeDisplayingContext.Shape.DisqusUniqueId = GetUniqueIdentifier(shapeDisplayingContext.Shape.ContentPart.ContentItem);
shapeDisplayingContext.ShapeMetadata.Wrappers.Add("CountWrapper");
});
builder.Describe("Parts_Blogs_BlogPost_List")
.OnDisplaying(shapeDisplayingContext =>
{
var settings = this.orchardServices.WorkContext.CurrentSite.As<DisqusSettingsPart>();
shapeDisplayingContext.Shape.DisqusSettings = settings;
shapeDisplayingContext.ShapeMetadata.Wrappers.Add("ListWrapper");
});
}
示例8: Discover
public void Discover(ShapeTableBuilder builder) {
builder.Describe("Content_Edit")
.OnDisplaying(displaying => {
var shape = displaying.Shape;
shape.Metadata.Alternates.Add("Content_Edit__Default");
});
}
示例9: GetShapeTable
public ShapeTable GetShapeTable(string themeName)
{
// Use a lazy initialized factory to prevent multiple threads from building
// the same table in parallel as it is costly
return _shapeTables.GetOrAdd(themeName ?? "", new Lazy<ShapeTable>(() =>
{
_logger.LogInformation("Start building shape table");
IList<IReadOnlyList<ShapeAlteration>> alterationSets = new List<IReadOnlyList<ShapeAlteration>>();
foreach (var bindingStrategy in _bindingStrategies)
{
Feature strategyDefaultFeature =
_typeFeatureProvider.GetFeatureForDependency(bindingStrategy.GetType());
var builder = new ShapeTableBuilder(strategyDefaultFeature);
bindingStrategy.Discover(builder);
var builtAlterations = builder.BuildAlterations().ToReadOnlyCollection();
if (builtAlterations.Any())
{
alterationSets.Add(builtAlterations);
}
}
var alterations = alterationSets
.SelectMany(shapeAlterations => shapeAlterations)
.Where(alteration => IsModuleOrRequestedTheme(alteration, themeName))
.OrderByDependenciesAndPriorities(AlterationHasDependency, GetPriority)
.ToList();
var descriptors = alterations.GroupBy(alteration => alteration.ShapeType, StringComparer.OrdinalIgnoreCase)
.Select(group => group.Aggregate(
new ShapeDescriptor { ShapeType = group.Key },
(descriptor, alteration) =>
{
alteration.Alter(descriptor);
return descriptor;
})).ToList();
foreach (var descriptor in descriptors)
{
foreach (var alteration in alterations.Where(a => a.ShapeType == descriptor.ShapeType).ToList())
{
var local = new ShapeDescriptor { ShapeType = descriptor.ShapeType };
alteration.Alter(local);
descriptor.BindingSources.Add(local.BindingSource);
}
}
var result = new ShapeTable
{
Descriptors = descriptors.ToDictionary(sd => sd.ShapeType, StringComparer.OrdinalIgnoreCase),
Bindings = descriptors.SelectMany(sd => sd.Bindings).ToDictionary(kv => kv.Key, kv => kv.Value, StringComparer.OrdinalIgnoreCase),
};
//await _eventBus.NotifyAsync<IShapeTableEventHandler>(x => x.ShapeTableCreated(result));
_logger.LogInformation("Done building shape table");
return result;
})).Value;
}
示例10: Discover
public void Discover(ShapeTableBuilder builder)
{
builder.Describe("Parts_MenuWidget").OnDisplaying(context =>
{
var contentItem = (ContentItem)context.Shape.ContentItem;
var widgetPart = contentItem.As<WidgetPart>();
var menuWidgetPart = contentItem.As<MenuWidgetPart>();
var menuShape = context.Shape.Menu;
var widgetName = widgetPart.Name.ToSafeName();
var menu = mMenuService.Value.GetMenu(menuWidgetPart.MenuContentItemId);
var menuName = menu.As<TitlePart>().Title.ToSafeName();
var zoneName = widgetPart.Zone;
if (!String.IsNullOrWhiteSpace(widgetName))
context.ShapeMetadata.Alternates.Add($"Parts_MenuWidget__WidgetName__{widgetName}");
context.ShapeMetadata.Alternates.Add($"Parts_MenuWidget__MenuName__{menuName}");
context.ShapeMetadata.Alternates.Add($"Parts_MenuWidget__MenuLevel__{menuWidgetPart.StartLevel}");
context.ShapeMetadata.Alternates.Add($"Parts_MenuWidget__MenuName__{menuName}__MenuLevel{menuWidgetPart.StartLevel}");
context.ShapeMetadata.Alternates.Add($"Parts_MenuWidget__Zone__{zoneName}");
context.ShapeMetadata.Alternates.Add($"Parts_MenuWidget__Zone__{zoneName}__MenuName__{menuName}");
menuShape.MenuWidget = contentItem;
menuShape.SafeMenuName = menuName;
});
builder.Describe("Menu").OnDisplaying(ConfigureMenuShape);
builder.Describe("Breadcrumb").OnDisplaying(ConfigureMenuShape);
}
示例11: Discover
public void Discover(ShapeTableBuilder builder) {
builder.Describe("Post_Body_Editor")
.OnDisplaying(displaying => {
string flavor = displaying.Shape.EditorFlavor;
displaying.ShapeMetadata.Alternates.Add("Post_Body_Editor__" + flavor);
});
// We support multiple forum types, but need to be able to skin forum admin shapes, so add alternates for any content type that has a ForumPart.
builder.Describe("Content").OnDisplaying(displaying => {
var content = (ContentItem) displaying.Shape.ContentItem;
if (content.Parts.All(x => x.PartDefinition.Name != typeof (ForumPart).Name))
return;
var displayType = !String.IsNullOrWhiteSpace(displaying.ShapeMetadata.DisplayType) ? displaying.ShapeMetadata.DisplayType : "Detail";
var alternates = new[] {
string.Format("Content__{0}", content.ContentType),
string.Format("Content__{0}_{1}", content.ContentType, displayType),
};
foreach (var alternate in alternates.Where(alternate => !displaying.ShapeMetadata.Alternates.Contains(alternate))) {
displaying.ShapeMetadata.Alternates.Add(alternate);
}
});
}
示例12: Discover
public void Discover(ShapeTableBuilder builder)
{
builder.Describe("Foo")
.OnDisplaying(displaying =>
displaying.ChildContent = new HtmlString("<h1>Hi</h1>")
);
}
示例13: Discover
public void Discover(ShapeTableBuilder builder) {
builder.Describe("Body_Editor")
.OnDisplaying(displaying => {
string flavor = displaying.Shape.EditorFlavor;
displaying.ShapeMetadata.Alternates.Add("Body_Editor__" + flavor);
});
}
示例14: Discover
public void Discover(ShapeTableBuilder builder) {
builder.Describe("Menu")
.OnDisplaying(displaying =>
{
string displayType = displaying.Shape.DisplayType;
if (!string.IsNullOrWhiteSpace(displayType))
{
displaying.Shape.Metadata.Alternates.Add("Menu_" + EncodeAlternateElement(displayType));
}
});
builder.Describe("MenuItem")
.OnDisplaying(displaying =>
{
string displayType = displaying.Shape.Menu.DisplayType;
if (!string.IsNullOrWhiteSpace(displayType))
{
displaying.Shape.Metadata.Alternates.Add("MenuItem_" + EncodeAlternateElement(displayType));
}
});
builder.Describe("MenuItemLink")
.OnDisplaying(displaying =>
{
string displayType = displaying.Shape.Menu.DisplayType;
if (!string.IsNullOrWhiteSpace(displayType))
{
displaying.Shape.Metadata.Alternates.Add("MenuItemLink_" + EncodeAlternateElement(displayType));
}
});
}
示例15: Discover
public void Discover(ShapeTableBuilder builder) {
builder.Describe("Content")
.OnCreated(created => {
var content = created.Shape;
content.Child.Add(created.New.PlaceChildContent(Source: content));
})
.OnDisplaying(displaying => {
ContentItem contentItem = displaying.Shape.ContentItem;
if (contentItem != null) {
// Alternates in order of specificity.
// Display type > content type > specific content > display type for a content type > display type for specific content
// BasicShapeTemplateHarvester.Adjust will then adjust the template name
// Content__[DisplayType] e.g. Content-Summary
displaying.ShapeMetadata.Alternates.Add("Content_" + EncodeAlternateElement(displaying.ShapeMetadata.DisplayType));
// Content__[ContentType] e.g. Content-BlogPost,
displaying.ShapeMetadata.Alternates.Add("Content__" + EncodeAlternateElement(contentItem.ContentType));
// Content__[Id] e.g. Content-42,
displaying.ShapeMetadata.Alternates.Add("Content__" + contentItem.Id);
// Content_[DisplayType]__[ContentType] e.g. Content-BlogPost.Summary
displaying.ShapeMetadata.Alternates.Add("Content_" + displaying.ShapeMetadata.DisplayType + "__" + EncodeAlternateElement(contentItem.ContentType));
// Content_[DisplayType]__[Id] e.g. Content-42.Summary
displaying.ShapeMetadata.Alternates.Add("Content_" + displaying.ShapeMetadata.DisplayType + "__" + contentItem.Id);
}
});
}