本文整理汇总了C#中IContent.Parent方法的典型用法代码示例。如果您正苦于以下问题:C# IContent.Parent方法的具体用法?C# IContent.Parent怎么用?C# IContent.Parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContent
的用法示例。
在下文中一共展示了IContent.Parent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddParentForumCaches
private List<string> AddParentForumCaches(IContent item, List<string> cacheList)
{
var parent = item.Parent();
if (parent != null)
{
if (parent.ContentTypeId == forumContentTypeId || parent.ContentTypeId == postContentTypeId)
{
var cache = string.Format("simpilyforum_{0}", parent.Id);
if (!cacheList.Contains(cache))
cacheList.Add(cache);
cacheList = AddParentForumCaches(parent, cacheList);
}
}
return cacheList;
}
示例2: GetContentPath
private string GetContentPath(IContent content)
{
// works out the path for our content
string path = "";
path = helpers.FileHelper.CleanFileName(content.Name);
if (content.ParentId != -1)
{
path = String.Format("{0}\\{1}", GetContentPath(content.Parent()), path);
}
return path;
}
示例3: ExportContent
public XElement ExportContent(IContent content)
{
LogHelper.Info(typeof(ContentExporter), String.Format("Exporting content {0}", FileHelper.CleanFileName(content.Name)));
var nodeName = UmbracoSettings.UseLegacyXmlSchema ? "node" : FileHelper.CleanFileName(content.ContentType.Alias);
// XElement xml = new XElement(nodeName);
XElement xml = uSyncXmlHelper.ExportContentBase(nodeName, content);
// core content item properties
xml.Add(new XAttribute("parentGUID", content.Level > 1 ? content.Parent().Key : new Guid("00000000-0000-0000-0000-000000000000")));
xml.Add(new XAttribute("nodeTypeAlias", content.ContentType.Alias));
xml.Add(new XAttribute("templateAlias", content.Template == null ? "" : content.Template.Alias));
xml.Add(new XAttribute("sortOrder", content.SortOrder));
xml.Add(new XAttribute("published", content.Published));
return xml;
}
示例4: SearchAncestorForProperty
private object SearchAncestorForProperty(IContent document, string alias)
{
if (document.Properties.Any(n => n.Alias == alias))
return document.Properties[alias].Value;
else
if (document.Level > 1)
return SearchAncestorForProperty(document.Parent(), alias);
else
return null;
}
示例5: UnVersion
public void UnVersion(IContent content)
{
var configEntries = new List<UnVersionConfigEntry>();
if (_config.ConfigEntries.ContainsKey(content.ContentType.Alias))
configEntries.AddRange(_config.ConfigEntries[content.ContentType.Alias]);
if (_config.ConfigEntries.ContainsKey("$_ALL"))
configEntries.AddRange(_config.ConfigEntries["$_ALL"]);
if (configEntries.Count <= 0)
{
if (Logger.IsDebugEnabled)
Logger.Debug("No unversion configuration found for type " + content.ContentType.Alias);
return;
}
foreach (var configEntry in configEntries)
{
var isValid = true;
if (!String.IsNullOrEmpty(configEntry.RootXPath))
{
if (content.Level > 1 && content.Parent() != null)
{
var ids = GetNodeIdsFromXpath(configEntry.RootXPath);
isValid = ids.Contains(content.ParentId);
}
}
if (!isValid)
continue;
using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings[ "umbracoDbDSN" ].ConnectionString))
{
connection.Open();
var vesionsToKeep = VersionsToKeep( content.Id, configEntry, connection );
var versionsToKeepString = string.Join( ",", vesionsToKeep );
if (Logger.IsDebugEnabled)
Logger.Debug("Keeping versions " + versionsToKeepString);
var sqlStrings = new List<string> {
string.Format(@"
DELETE
FROM cmsPreviewXml
WHERE nodeId = {0} AND versionId NOT IN ({1})",
content.Id,
versionsToKeepString),
string.Format(@"
DELETE
FROM cmsPropertyData
WHERE contentNodeId = {0} AND versionId NOT IN ({1})",
content.Id,
versionsToKeepString),
string.Format(@"
DELETE
FROM cmsContentVersion
WHERE contentId = {0} AND versionId NOT IN ({1})",
content.Id,
versionsToKeepString),
string.Format(@"
DELETE
FROM cmsDocument
WHERE nodeId = {0} AND versionId NOT IN ({1})",
content.Id,
versionsToKeepString)
};
foreach (var sqlString in sqlStrings)
{
ExecuteSql(sqlString, connection);
}
}
}
}
示例6: SerialiseContent
/// <summary>
/// Serialize IContent to XElement and adds dependent nodes
/// </summary>
/// <param name="content">Umbraco IContent object</param>
/// <param name="dependantNodes">this function will add dependent nodes to this collection</param>
/// <returns>returns serialized version of IContent as XElement</returns>
public XElement SerialiseContent(IContent content, Dictionary<int, ObjectTypes> dependantNodes = null)
{
dependantNodes = dependantNodes ?? new Dictionary<int, ObjectTypes>();
var nodeName = content.ContentType.Alias.ToSafeAliasWithForcingCheck();
var currentContent = new XElement(nodeName,
new XAttribute("nodeName", content.Name),
new XAttribute("nodeType", content.ContentType.Id),
new XAttribute("creatorName", content.GetCreatorProfile().Name),
new XAttribute("writerName", content.GetWriterProfile().Name),
new XAttribute("writerID", content.WriterId),
new XAttribute("templateID", content.Template == null ? "0" : content.Template.Id.ToString(CultureInfo.InvariantCulture)),
new XAttribute("nodeTypeAlias", content.ContentType.Alias),
new XAttribute("id", content.Id),
new XAttribute("parentID", content.Level > 1 ? content.ParentId : -1),
new XAttribute("level", content.Level),
new XAttribute("creatorID", content.CreatorId),
new XAttribute("sortOrder", content.SortOrder),
new XAttribute("createDate", content.CreateDate.ToString("s")),
new XAttribute("updateDate", content.UpdateDate.ToString("s")),
new XAttribute("path", content.Path),
new XAttribute("isDoc", string.Empty),
new XAttribute("releaseDate", content.ReleaseDate != null ? content.ReleaseDate.Value.ToString("s") : DateTime.MinValue.ToString("s")),
new XAttribute("expireDate", content.ExpireDate != null ? content.ExpireDate.Value.ToString("s") : DateTime.MinValue.ToString("s")),
new XAttribute("parentGuid", content.Level > 1 ? content.Parent().Key.ToString() : string.Empty),
new XAttribute("guid", content.Key),
new XAttribute("objectType", ObjectTypes.Document),
new XAttribute("published", content.Published));
var propertyTypes = content.PropertyTypes.ToArray();
var count = 0;
foreach (var property in content.Properties)
{
var tag = property.ToXml();
var propertyType = propertyTypes.ElementAt(count);
tag.Add(new XAttribute("dataTypeGuid", propertyType.DataTypeId));
tag.Add(new XAttribute("dataTypeName", Services.DataTypeService.GetDataTypeDefinitionById(propertyType.DataTypeDefinitionId).Name));
var guid = propertyTypes.ElementAt(count).DataTypeId;
// TODO for v6
if (guid == new Guid(Constants.UploadDataTypeGuid) && property.Value != null)
{
var umbracoFile = property.Value.ToString();
tag.Add(
new XAttribute("umbracoFile", umbracoFile),
new XAttribute("fileName", umbracoFile.Split('/').Last()),
new XAttribute("objectType", ObjectTypes.File));
}
else if (SpecialDataTypes.ContainsKey(guid))
{
DataTypeConverterExport(property, tag, dependantNodes, SpecialDataTypes[guid]);
}
currentContent.Add(tag);
count++;
}
return currentContent;
}
示例7: RecursivelyGetParentsDomains
private List<string> RecursivelyGetParentsDomains(List<string> domains, IContent content)
{
//Termination case
if(content == null)
{
return domains;
}
domains.AddRange(ApplicationContext.Current.Services.DomainService.GetAssignedDomains(content.Id, false).Select(x => x.DomainName));
domains = RecursivelyGetParentsDomains(domains, content.Parent());
return domains;
}