本文整理汇总了C#中Term.GetDefaultLabel方法的典型用法代码示例。如果您正苦于以下问题:C# Term.GetDefaultLabel方法的具体用法?C# Term.GetDefaultLabel怎么用?C# Term.GetDefaultLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Term
的用法示例。
在下文中一共展示了Term.GetDefaultLabel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TaxonomyValue
/// <summary>
/// Initializes a new instance of the <see cref="TaxonomyValue"/> class.
/// </summary>
/// <param name="term">The term.</param>
public TaxonomyValue(Term term)
{
if (term == null)
{
throw new ArgumentNullException("term");
}
this.Id = term.Id;
// Respect the current user's MUI language selection
string currentUiLabel = term.GetDefaultLabel(CultureInfo.CurrentUICulture.LCID);
if (!string.IsNullOrEmpty(currentUiLabel))
{
this.Label = currentUiLabel;
}
else if (term.Labels.Count > 0)
{
// if no label exists in the current UI language, just fall back on the first of the bunch
this.Label = term.Labels[0].Value;
}
this.CustomSortPosition = GetCustomSortOrderFromParent(term);
}
示例2: GetTermDefaultLabelsForWorkingLanguages
private Dictionary<CultureInfo, string> GetTermDefaultLabelsForWorkingLanguages(Term term)
{
var dictionary = new Dictionary<CultureInfo, string>();
var cultures = term.TermSet.Group.TermStore.Languages.Select(lang => new CultureInfo(lang));
foreach (CultureInfo culture in cultures)
{
var labelForCulture = term.GetDefaultLabel(culture.LCID);
if (!string.IsNullOrEmpty(labelForCulture))
{
dictionary[culture] = labelForCulture;
}
}
return dictionary;
}