本文整理汇总了C#中IContentType.RemovePropertyType方法的典型用法代码示例。如果您正苦于以下问题:C# IContentType.RemovePropertyType方法的具体用法?C# IContentType.RemovePropertyType怎么用?C# IContentType.RemovePropertyType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContentType
的用法示例。
在下文中一共展示了IContentType.RemovePropertyType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyProperties
/// <summary>
/// Loop through all properties and remove existing ones if necessary
/// </summary>
/// <param name="contentType"></param>
/// <param name="type"></param>
/// <param name="dataTypeService"></param>
private static void VerifyProperties(IContentType contentType, Type type, IDataTypeService dataTypeService)
{
var properties = type.GetProperties().Where(x => x.GetCustomAttribute<UmbracoTabAttribute>() != null).ToArray();
List<string> propertiesThatShouldExist = new List<string>();
foreach (var propertyTab in properties)
{
var tabAttribute = propertyTab.GetCustomAttribute<UmbracoTabAttribute>();
if (!contentType.PropertyGroups.Any(x => x.Name == tabAttribute.Name))
{
contentType.AddPropertyGroup(tabAttribute.Name);
}
propertiesThatShouldExist.AddRange(VerifyAllPropertiesOnTab(propertyTab, contentType, tabAttribute.Name, dataTypeService));
}
var propertiesOfRoot = type.GetProperties().Where(x => x.GetCustomAttribute<UmbracoPropertyAttribute>() != null);
foreach (var item in propertiesOfRoot)
{
//TODO: check for correct name
propertiesThatShouldExist.Add(VerifyExistingProperty(contentType, null, dataTypeService, item, true));
}
//loop through all the properties on the ContentType to see if they should be removed;
var existingUmbracoProperties = contentType.PropertyTypes.ToArray();
int length = contentType.PropertyTypes.Count();
for (int i = 0; i < length; i++)
{
if (!propertiesThatShouldExist.Contains(existingUmbracoProperties[i].Alias))
{
//remove the property
contentType.RemovePropertyType(existingUmbracoProperties[i].Alias);
}
}
}