本文整理汇总了C#中umbraco.cms.businesslogic.web.DocumentType.AddPropertyType方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentType.AddPropertyType方法的具体用法?C# DocumentType.AddPropertyType怎么用?C# DocumentType.AddPropertyType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类umbraco.cms.businesslogic.web.DocumentType
的用法示例。
在下文中一共展示了DocumentType.AddPropertyType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateProperties
void UpdateProperties(XDocument xmlDoc, DocumentType docType)
{
var updatedProperties = xmlDoc.Descendants("GenericProperty");
var updatedPropertiesNames = updatedProperties.Select(x => x.Element("Alias").Value);
var props = PropertyType.GetAll().Where(x => x.ContentTypeId == docType.Id);
var matchingProps = props.Where(x => updatedPropertiesNames.Contains(x.Alias));
var toDelete = props.Where(x => !matchingProps.Contains(x));
var newProperties = updatedProperties.Where(x => !matchingProps.Select(y => y.Alias).Contains(x.Element("Alias").Value));
foreach (var p in toDelete)
{
p.delete();
}
var allDtd = DataTypeDefinition.GetAll();
var tabs = docType.getVirtualTabs;
foreach (var p in matchingProps)
{
var match = updatedProperties.Where(x => x.Element("Alias").Value == p.Alias).Single();
var dtd = allDtd.Where(x => x.UniqueId == new Guid(match.Element("Definition").Value)).Single();
p.DataTypeDefinition = dtd;
p.Description = match.Element("Description").Value;
var t = tabs.Where(x => x.Caption == match.Element("Tab").Value).FirstOrDefault();
if (t != null)
p.TabId = t.Id;
p.Mandatory = bool.Parse(match.Element("Mandatory").Value);
p.ValidationRegExp = match.Element("Validation").Value;
p.Name = match.Element("Name").Value;
p.Save();
}
foreach (var m in newProperties)
{
var dtd = allDtd.Where(x => x.UniqueId == new Guid(m.Element("Definition").Value)).Single();
var p = docType.AddPropertyType(dtd, m.Element("Alias").Value, m.Element("Name").Value);
p.Description = m.Element("Description").Value;
var t = tabs.Where(x => x.Caption == m.Element("Tab").Value).FirstOrDefault();
if (t != null)
p.TabId = t.Id;
p.Mandatory = bool.Parse(m.Element("Mandatory").Value);
p.ValidationRegExp = m.Element("Validation").Value;
p.Save();
}
}