本文整理汇总了C#中SPListItem.TraverseItemLookups方法的典型用法代码示例。如果您正苦于以下问题:C# SPListItem.TraverseItemLookups方法的具体用法?C# SPListItem.TraverseItemLookups怎么用?C# SPListItem.TraverseItemLookups使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPListItem
的用法示例。
在下文中一共展示了SPListItem.TraverseItemLookups方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadUsers
/// <summary>
/// Nacte uzivatele pro ktere se maji priradit prava
/// </summary>
/// <param name="item"></param>
/// <param name="identifications">muze byt login, jmeno pole ze ktereho se nactou uzivatele a nebo lookup a pak pole ze ktereho se to nacte</param>
/// <param name="expandUsers"></param>
/// <returns></returns>
private static List<SPPrincipal> LoadUsers(SPListItem item, List<string> identifications, bool expandUsers)
{
List<SPPrincipal> users = new List<SPPrincipal>();
foreach (string identification in identifications)
{
if (item.ParentList.ContainsFieldIntName(identification)) //je jmeno pole
{
if (item[identification] != null)
{
var fieldUsers = item.Web.GetSPPrincipals(item[identification]);
users.AddRange(fieldUsers);
}
}
else if (identification.Contains("\\")) //obsahuje login - at uz s claims nebo bez
{
List<SPPrincipal> principals = item.Web.GetSPPrincipals(identification.Split(';')); //bacha aby tady nebylo v claims vice stredniku!!
users.AddRange(principals);
}
else if (identification.Contains('|')) //Lookupový zápis
{
List<string> fields = identification.Split('|').ToList();
string userField = fields.Last();
fields.RemoveAt(fields.Count - 1);
WebListItemDictionary wild = item.TraverseItemLookups(fields);
wild.ProcessItems(item.Web.Site, delegate(SPListItem lookupItem)
{
if (lookupItem[userField] != null)
{
List<SPPrincipal> principals = lookupItem.Web.GetSPPrincipals(lookupItem[userField]);
if (principals != null)
{
users.AddRange(principals);
}
}
return null;
});
}
else
{
//nemelo by diky konfiguraci nikdy nastat
}
}
users = users.Distinct(new SPPrincipalComparer()).ToList();
return expandUsers ? item.Web.GetSPUsers(users).Cast<SPPrincipal>().ToList() : users;
}