本文整理汇总了C#中IContent.Children方法的典型用法代码示例。如果您正苦于以下问题:C# IContent.Children方法的具体用法?C# IContent.Children怎么用?C# IContent.Children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContent
的用法示例。
在下文中一共展示了IContent.Children方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddUrlMapping
public static bool AddUrlMapping(IContent content, int rootNodeId, string url, AutoTrackingTypes type, bool isChild = false)
{
if (url != "#" && content.Template != null && content.Template.Id > 0)
{
string notes = isChild ? "An ancestor" : "This page";
switch (type)
{
case AutoTrackingTypes.Moved:
notes += " was moved";
break;
case AutoTrackingTypes.Renamed:
notes += " was renamed";
break;
case AutoTrackingTypes.UrlOverwritten:
notes += "'s property 'umbracoUrlName' changed";
break;
}
url = UrlTrackerHelper.ResolveShortestUrl(url);
if (!string.IsNullOrEmpty(url))
{
string query = "SELECT 1 FROM icUrlTracker WHERE RedirectNodeId = @nodeId AND OldUrl = @url";
int exists = _sqlHelper.ExecuteScalar<int>(query, _sqlHelper.CreateParameter("nodeId", content.Id), _sqlHelper.CreateStringParameter("url", url));
if (exists != 1)
{
LoggingHelper.LogInformation("UrlTracker Repository | Adding mapping for node id: {0} and url: {1}", new string[] { content.Id.ToString(), url });
query = "INSERT INTO icUrlTracker (RedirectRootNodeId, RedirectNodeId, OldUrl, Notes) VALUES (@rootNodeId, @nodeId, @url, @notes)";
_sqlHelper.ExecuteNonQuery(query, _sqlHelper.CreateParameter("rootNodeId", rootNodeId), _sqlHelper.CreateParameter("nodeId", content.Id), _sqlHelper.CreateStringParameter("url", url), _sqlHelper.CreateStringParameter("notes", notes));
if (content.Children().Any())
{
foreach (IContent child in content.Children())
{
Node node = new Node(child.Id);
AddUrlMapping(child, rootNodeId, node.NiceUrl, type, true);
}
}
return true;
}
}
}
return false;
}
示例2: UpdateAttendeeList
private void UpdateAttendeeList(IContent content, string attendeesJson)
{
var attendeesDic = JsonConvert.DeserializeObject<IEnumerable<Attendee>>(attendeesJson).ToDictionary(x => x.Id, x => x);
// check/create folder
var registrantsFolder = content.Children().FirstOrDefault(x => x.ContentType.Alias == "Registrants");
if (registrantsFolder == null)
{
registrantsFolder = Services.ContentService.CreateContent("Registrants", content.Id, "Registrants");
Services.ContentService.PublishWithStatus(registrantsFolder);
}
var existingAttendees = new List<string>();
foreach (var oldPerson in registrantsFolder.Children())
{
if (attendeesDic.ContainsKey(oldPerson.Id.ToString()))
{
var newPerson = attendeesDic[oldPerson.Id.ToString()];
if (oldPerson.GetValue<string>("name") != newPerson.Name ||
oldPerson.GetValue<string>("email") != newPerson.Email ||
oldPerson.GetValue<string>("phoneNumber") != newPerson.Phone)
{
// edit
oldPerson.SetValue("name", newPerson.Name);
oldPerson.SetValue("email", newPerson.Email);
oldPerson.SetValue("phoneNumber", newPerson.Phone);
Services.ContentService.PublishWithStatus(oldPerson);
}
existingAttendees.Add(oldPerson.Id.ToString());
}
else
{
// delete
Services.ContentService.Delete(oldPerson);
}
}
foreach (var person in attendeesDic.Values)
{
if (existingAttendees.Contains(person.Id)) continue;
// new
var newperson = Services.ContentService.CreateContent(person.Name, registrantsFolder.Id, "Person");
newperson.SetValue("name", person.Name);
newperson.SetValue("email", person.Email);
newperson.SetValue("phoneNumber", person.Phone);
Services.ContentService.PublishWithStatus(newperson);
}
}
示例3: ExportContent
private XElement ExportContent(IContent item)
{
LogHelper.Info<BasicNavParser>("Exporting {0}", () => item.Name);
var node = uSyncCore.Content.Export(item);
if (item.Children().Count() > 0)
{
var childHolder = new XElement("Children");
foreach (var child in item.Children())
{
var childNode = ExportContent(child);
childHolder.Add(childNode);
}
node.Add(childHolder);
}
return node;
}
示例4: GenerateJsonForTree
private Node GenerateJsonForTree(IContent content)
{
var isFolder = content.Children().Any();
var temp = new Node
{
title = content.Name,
key = content.Id.ToString(),
folder = isFolder,
lazy = isFolder
};
return temp;
}