本文整理汇总了C#中IContentType.RemovePropertyGroup方法的典型用法代码示例。如果您正苦于以下问题:C# IContentType.RemovePropertyGroup方法的具体用法?C# IContentType.RemovePropertyGroup怎么用?C# IContentType.RemovePropertyGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContentType
的用法示例。
在下文中一共展示了IContentType.RemovePropertyGroup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateContentType
/// <summary>
/// Update the existing content Type based on the data in the attributes
/// </summary>
/// <param name="contentTypeService"></param>
/// <param name="fileService"></param>
/// <param name="attribute"></param>
/// <param name="contentType"></param>
/// <param name="type"></param>
/// <param name="dataTypeService"></param>
private static void UpdateContentType(IContentTypeService contentTypeService, IFileService fileService, UmbracoContentTypeAttribute attribute, IContentType contentType, Type type, IDataTypeService dataTypeService)
{
contentType.Name = attribute.ContentTypeName;
contentType.Alias = attribute.ContentTypeAlias;
contentType.Icon = attribute.Icon;
contentType.IsContainer = attribute.EnableListView;
contentType.AllowedContentTypes = FetchAllowedContentTypes(attribute.AllowedChildren, contentTypeService);
contentType.AllowedAsRoot = attribute.AllowedAtRoot;
Type parentType = type.BaseType;
if (parentType != null && parentType != typeof(UmbracoGeneratedBase) && parentType.GetBaseTypes(false).Any(x => x == typeof(UmbracoGeneratedBase)))
{
UmbracoContentTypeAttribute parentAttribute = parentType.GetCustomAttribute<UmbracoContentTypeAttribute>();
if (parentAttribute != null)
{
string parentAlias = parentAttribute.ContentTypeAlias;
IContentType parentContentType = contentTypeService.GetContentType(parentAlias);
contentType.ParentId = parentContentType.Id;
}
else
{
throw new Exception("The given base class has no UmbracoContentTypeAttribute");
}
}
if (attribute.CreateMatchingView)
{
Template currentTemplate = fileService.GetTemplate(attribute.ContentTypeAlias) as Template;
if (currentTemplate == null)
{
//there should be a template but there isn't so we create one
currentTemplate = new Template("~/Views/" + attribute.ContentTypeAlias + ".cshtml", attribute.ContentTypeName, attribute.ContentTypeAlias);
CreateViewFile(attribute.ContentTypeAlias, attribute.MasterTemplate, currentTemplate, type, fileService);
fileService.SaveTemplate(currentTemplate, 0);
}
contentType.AllowedTemplates = new ITemplate[] { currentTemplate };
contentType.SetDefaultTemplate(currentTemplate);
}
VerifyProperties(contentType, type, dataTypeService);
//verify if a tab has no properties, if so remove
var propertyGroups = contentType.PropertyGroups.ToArray();
int length = propertyGroups.Length;
for (int i = 0; i < length; i++)
{
if (propertyGroups[i].PropertyTypes.Count == 0)
{
//remove
contentType.RemovePropertyGroup(propertyGroups[i].Name);
}
}
//persist
contentTypeService.Save(contentType, 0);
}