本文整理汇总了C#中IContentDefinitionManager.AlterTypeDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# IContentDefinitionManager.AlterTypeDefinition方法的具体用法?C# IContentDefinitionManager.AlterTypeDefinition怎么用?C# IContentDefinitionManager.AlterTypeDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContentDefinitionManager
的用法示例。
在下文中一共展示了IContentDefinitionManager.AlterTypeDefinition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MarkdownSiteSettingsPartHandler
public MarkdownSiteSettingsPartHandler(IContentDefinitionManager contentDefinitionManager) {
_contentDefinitionManager = contentDefinitionManager;
Filters.Add(new ActivatingFilter<MarkdownSiteSettingsPart>("Site"));
Filters.Add(new TemplateFilterForPart<MarkdownSiteSettingsPart>("MarkdownSiteSettings", "Parts/Markdown.MarkdownSiteSettings", "markdown"));
OnInitializing<MarkdownSiteSettingsPart>((context, part) => {
part.UseMarkdownForBlogs = false;
});
OnUpdated<MarkdownSiteSettingsPart>((context, part) => {
var blogPost = _contentDefinitionManager.GetTypeDefinition("BlogPost");
if (blogPost == null) {
return;
}
var bodyPart = blogPost.Parts.FirstOrDefault(x => x.PartDefinition.Name == "BodyPart");
if (bodyPart == null) {
return;
}
_contentDefinitionManager.AlterTypeDefinition("BlogPost", build => build
.WithPart("BodyPart", cfg => cfg
.WithSetting("BodyTypePartSettings.Flavor", part.UseMarkdownForBlogs ? "markdown" : "html")
)
);
});
T = NullLocalizer.Instance;
}
示例2: SetupRepoPageContentType
public static void SetupRepoPageContentType(IContentDefinitionManager contentDefinitionManager, string pageContentTypeName)
{
contentDefinitionManager.AlterTypeDefinition(pageContentTypeName,
cfg => cfg
.WithPart("TitlePart")
.WithPart("CommonPart")
.WithPart("AutoroutePart", builder => builder
.WithSetting("AutorouteSettings.AllowCustomPattern", "false")
.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "true")
.WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-page'}]")
.WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))
.WithPart(typeof(MarkdownPagePart).Name)
.WithPart("BodyPart", builder => builder
.WithSetting("BodyTypePartSettings.Flavor", "markdown"))
);
}