本文整理汇总了C#中TermStore.GetTermSetsByName方法的典型用法代码示例。如果您正苦于以下问题:C# TermStore.GetTermSetsByName方法的具体用法?C# TermStore.GetTermSetsByName怎么用?C# TermStore.GetTermSetsByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TermStore
的用法示例。
在下文中一共展示了TermStore.GetTermSetsByName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LookupTermSet
public static TermSet LookupTermSet(ClientRuntimeContext context, TermStore termStore,
Site site,
string termGroupName, Guid? termGroupId, bool? isSiteCollectionGroup,
string termSetName, Guid? termSetId, int termSetLCID)
{
var storeContext = context;
TermGroup currenGroup = null;
if (!string.IsNullOrEmpty(termGroupName))
{
currenGroup = termStore.Groups.GetByName(termGroupName);
storeContext.Load(currenGroup);
storeContext.ExecuteQueryWithTrace();
}
else if (termGroupId != null && termGroupId.HasGuidValue())
{
currenGroup = termStore.Groups.GetById(termGroupId.Value);
storeContext.Load(currenGroup);
storeContext.ExecuteQueryWithTrace();
}
else if (isSiteCollectionGroup == true)
{
currenGroup = termStore.GetSiteCollectionGroup(site, false);
storeContext.Load(currenGroup);
storeContext.ExecuteQueryWithTrace();
}
if (!string.IsNullOrEmpty(termSetName))
{
if (currenGroup != null && (currenGroup.ServerObjectIsNull == false))
{
TermSet termSet = null;
var scope = new ExceptionHandlingScope(storeContext);
using (scope.StartScope())
{
using (scope.StartTry())
{
termSet = currenGroup.TermSets.GetByName(termSetName);
storeContext.Load(termSet);
}
using (scope.StartCatch())
{
}
}
storeContext.ExecuteQueryWithTrace();
if (termSet != null && termSet.ServerObjectIsNull == false)
{
storeContext.Load(termSet, g => g.Id);
storeContext.ExecuteQueryWithTrace();
return termSet;
}
}
else
{
var termSets = termStore.GetTermSetsByName(termSetName, termSetLCID);
storeContext.Load(termSets);
storeContext.ExecuteQueryWithTrace();
return termSets.FirstOrDefault();
}
}
if (termSetId.HasGuidValue())
{
if (currenGroup != null && (currenGroup.ServerObjectIsNull == false))
{
TermSet termSet = null;
var scope = new ExceptionHandlingScope(storeContext);
using (scope.StartScope())
{
using (scope.StartTry())
{
termSet = currenGroup.TermSets.GetById(termSetId.Value);
storeContext.Load(termSet);
}
using (scope.StartCatch())
{
}
}
storeContext.ExecuteQueryWithTrace();
if (termSet != null && termSet.ServerObjectIsNull == false)
{
storeContext.Load(termSet, g => g.Id);
storeContext.ExecuteQueryWithTrace();
//.........这里部分代码省略.........
示例2: LookupTermSet
public static TermSet LookupTermSet(ClientRuntimeContext context, TermStore termStore,
string termSetName, Guid? termSetId, int termSetLCID)
{
var storeContext = context;
if (!string.IsNullOrEmpty(termSetName))
{
var termSets = termStore.GetTermSetsByName(termSetName, termSetLCID);
storeContext.Load(termSets);
storeContext.ExecuteQueryWithTrace();
return termSets.FirstOrDefault();
}
if (termSetId.HasGuidValue())
{
TermSet termSet = null;
var scope = new ExceptionHandlingScope(storeContext);
using (scope.StartScope())
{
using (scope.StartTry())
{
termSet = termStore.GetTermSet(termSetId.Value);
storeContext.Load(termSet);
}
using (scope.StartCatch())
{
}
}
storeContext.ExecuteQueryWithTrace();
if (termSet != null && termSet.ServerObjectIsNull == false)
{
storeContext.Load(termSet, g => g.Id);
storeContext.ExecuteQueryWithTrace();
return termSet;
}
}
return null;
}