本文整理汇总了C#中Term.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Term.Select方法的具体用法?C# Term.Select怎么用?C# Term.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Term
的用法示例。
在下文中一共展示了Term.Select方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FilterNavigationNodesToRestrictedTermSet
private IEnumerable<NavigationNode> FilterNavigationNodesToRestrictedTermSet(SPWeb web, Guid restrictedTermSetId, IEnumerable<NavigationNode> nodes, Term[] restrictedTerms = null)
{
// If first pass, initialize the restricted nodes with first level terms
if (restrictedTerms == null)
{
// Get restricted term set
var session = new TaxonomySession(web.Site);
var termStore = session.DefaultSiteCollectionTermStore;
var termSet = termStore.GetTermSet(restrictedTermSetId);
restrictedTerms = termSet.Terms.ToArray();
}
// Flattened navigation nodes for easier search
var flattenedNodes = nodes.Flatten(node => node.ChildNodes);
var restrictedNodes = restrictedTerms.Select(term => flattenedNodes.SingleOrDefault(node => node.Id.Equals(term.Id))).ToArray();
for (var i = 0; i < restrictedTerms.Length; i++)
{
var restrictedTerm = restrictedTerms[i];
var restrictedNode = restrictedNodes[i];
// If term contains children, recurvise call
if (restrictedTerm.Terms.Count > 0)
{
restrictedNode.ChildNodes = this.FilterNavigationNodesToRestrictedTermSet(web, restrictedTermSetId, nodes, restrictedTerm.Terms.ToArray());
}
}
return restrictedNodes;
}
示例2: FilterNavigationNodesToRestrictedTermSet
private IEnumerable<NavigationNode> FilterNavigationNodesToRestrictedTermSet(SPWeb web, NavigationQueryParameters queryParameters, IEnumerable<NavigationNode> nodes, Term[] restrictedTerms = null)
{
// If first pass, initialize the restricted nodes with first level terms
if (restrictedTerms == null)
{
// Get restricted term set
var session = new TaxonomySession(web.Site);
TermStore termStore = null;
if (queryParameters.TermStoreId == Guid.Empty)
{
termStore = this.taxonomyHelper.GetDefaultSiteCollectionTermStore(session);
}
else
{
termStore = session.TermStores[queryParameters.TermStoreId];
}
var termSet = termStore.GetTermSet(queryParameters.RestrictedTermSetId);
var nodeMatchingSettings = queryParameters.NodeMatchingSettings;
if ((nodeMatchingSettings != null) && nodeMatchingSettings.RestrictToCurrentNavigationLevel)
{
var currentTermId = TaxonomyNavigationContext.Current.NavigationTerm.Id;
restrictedTerms = termSet.GetTerm(currentTermId).Parent.Terms.ToArray();
}
else
{
restrictedTerms = termSet.Terms.ToArray();
}
}
// Flattened navigation nodes for easier search
var flattenedNodes = nodes.Flatten(node => node.ChildNodes);
var restrictedNodes = restrictedTerms.Select(term => flattenedNodes.SingleOrDefault(node => node.Id.Equals(term.Id))).ToArray();
for (var i = 0; i < restrictedTerms.Length; i++)
{
var restrictedTerm = restrictedTerms[i];
var restrictedNode = restrictedNodes[i];
// If term contains children, recurvise call
if (restrictedTerm.Terms.Count > 0)
{
restrictedNode.ChildNodes = this.FilterNavigationNodesToRestrictedTermSet(web, queryParameters, nodes, restrictedTerm.Terms.ToArray());
}
else
{
restrictedNode.ChildNodes = new List<NavigationNode>();
}
}
return restrictedNodes;
}