本文整理汇总了C#中IItem.GetChildren方法的典型用法代码示例。如果您正苦于以下问题:C# IItem.GetChildren方法的具体用法?C# IItem.GetChildren怎么用?C# IItem.GetChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IItem
的用法示例。
在下文中一共展示了IItem.GetChildren方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Search
private void Search(IItem rootItem, string sFind)
{
foreach (IItem item in rootItem.GetChildren())
{
if (_bStop)
return;
tbSearchingIn.Text = item.Path;
foreach (IField field in item.Fields)
{
if (field.Content.ToLower().IndexOf(sFind.ToLower()) > -1)
{
lbSearchResult.Items.Add(item.Path);
lock (_itemsFound)
{
_itemsFound.Add(item.Path, item);
}
break;
}
}
Application.DoEvents();
_myExpandNode(item);
Application.DoEvents();
if (item.HasChildren())
{
Search(item, sFind);
}
}
}
示例2: Compare
private void Compare(IItem leftRootItem, IItem rightRootItem)
{
IItem[] rightChildren = rightRootItem.GetChildren();
IItem[] leftChildren = leftRootItem.GetChildren();
foreach (IItem leftItem in leftRootItem.GetChildren())
{
if (_bStop)
return;
tbSearchingIn.Text = leftItem.Path;
// Find the correct right hand item
IItem rightItem = rightChildren.FindItem(leftItem.ID);
if (rightItem == null)
{
lbCompareResult.Items.Add(leftItem.Path + " --> item not found in " + rightRootItem.Options.HostName);
lock (_leftItemsFound)
{
_leftItemsFound.Add(leftItem.ID.ToString(), leftItem);
}
continue;
}
// CompareFields(leftItem.Fields, rightItem.Fields);
// CompareFields(rightItem.Fields, leftItem.Fields);
foreach (IField leftField in leftItem.Fields)
{
// Find the correct right hand field
IField rightField = null;
foreach (IField field in rightItem.Fields)
{
if (field.TemplateFieldID == leftField.TemplateFieldID)
rightField = field;
}
// If field is missing then that counts for a diference
if (rightField == null)
{
// Also find missing fields
if (cbMissingFields.Checked)
{
if (leftField.TemplateFieldID == Util.GuidToSitecoreID(LOCKGUID))
continue;
lbCompareResult.Items.Add(leftItem.Path);
_leftItemsFound.Add(leftItem.ID.ToString(), leftItem);
_rightItemsFound.Add(rightItem.ID.ToString(), rightItem);
break;
}
else
continue;
}
// Compare all other fields than the Revision, which might always be different
if ((leftField.Content.ToLower() != rightField.Content.ToLower()) &&
(leftField.TemplateFieldID != Util.GuidToSitecoreID(REVISIONGUID)) &&
(leftField.TemplateFieldID != Util.GuidToSitecoreID(UPDATEDGUID)) &&
(leftField.TemplateFieldID != Util.GuidToSitecoreID(UPDATEDBYGUID)) &&
(leftField.TemplateFieldID != Util.GuidToSitecoreID(CREATEDGUID)) &&
(leftField.TemplateFieldID != Util.GuidToSitecoreID(CREATEDBYGUID)) &&
(leftField.TemplateFieldID != Util.GuidToSitecoreID(OWNERGUID))
)
{
lbCompareResult.Items.Add(leftItem.Path);
_leftItemsFound.Add(leftItem.ID.ToString(), leftItem);
_rightItemsFound.Add(rightItem.ID.ToString(), rightItem);
break;
}
}
Application.DoEvents();
_myExpandNode(leftItem, _leftSelectedTreeNode, _leftSelectedTreeView);
_myExpandNode(rightItem, _rightSelectedTreeNode, _rightSelectedTreeView);
Application.DoEvents();
if (leftItem.HasChildren())
{
Compare(leftItem, rightItem);
}
}
// Find left hand source
foreach (IItem rightItem in rightChildren)
{
IItem leftItem = leftChildren.FindItem(rightItem.ID);
if (leftItem == null)
{
lbCompareResult.Items.Add(rightItem.Path + " --> item not found in " + leftRootItem.Options.HostName);
lock (_rightItemsFound)
{
_rightItemsFound.Add(rightItem.ID.ToString(), rightItem);
}
}
}
}
示例3: CopyChildren
private void CopyChildren(Sitecore6xItem parentItem, IItem CopyFrom)
{
if (Util.backgroundWorker.CancellationPending)
return;
IItem[] sourceChildren = CopyFrom.GetChildren();
foreach (IItem child in sourceChildren)
{
if (Util.backgroundWorker.CancellationPending)
return;
try
{
Sitecore6xItem newItem = parentItem.CopyItemTo(child);
// recursively copy children
if (newItem != null)
CopyChildren(newItem, child);
}
catch (Exception ex)
{
if (Util.ExceptionContainsMessage(ex, "Unknown item"))
{
Util.AddWarning("Found an 'Unknown item' at: " + child.Path + ", the item is probably missing its template.");
continue;
}
else
throw new Exception("Error while copying from: " + child.Path, ex);
}
}
}