本文整理汇总了C#中Term.SetCustomProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Term.SetCustomProperty方法的具体用法?C# Term.SetCustomProperty怎么用?C# Term.SetCustomProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Term
的用法示例。
在下文中一共展示了Term.SetCustomProperty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MapTermProperties
protected void MapTermProperties(Term currentTerm, TaxonomyTermDefinition termModel)
{
if (!string.IsNullOrEmpty(termModel.Description))
currentTerm.SetDescription(termModel.Description, termModel.LCID);
if (!string.IsNullOrEmpty(termModel.CustomSortOrder))
currentTerm.CustomSortOrder = termModel.CustomSortOrder;
if (termModel.IsAvailableForTagging.HasValue)
currentTerm.IsAvailableForTagging = termModel.IsAvailableForTagging.Value;
#if !NET35
foreach (var customProp in termModel.CustomProperties.Where(p => p.Override))
{
currentTerm.SetCustomProperty(customProp.Name, customProp.Value);
}
#endif
#if !NET35
foreach (var customProp in termModel.LocalCustomProperties.Where(p => p.Override))
{
currentTerm.SetLocalCustomProperty(customProp.Name, customProp.Value);
}
#endif
}
示例2: UpdateTerm
private void UpdateTerm(ClientContext sourceClientContext, ClientContext targetClientContext, Term sourceTerm, Term targetTerm, List<int> languagesToProcess)
{
targetTerm.Name = sourceTerm.Name;
targetTerm.IsAvailableForTagging = sourceTerm.IsAvailableForTagging;
// Process custom properties
if (sourceTerm.LocalCustomProperties.Count > 0)
{
// add properties from source
foreach (KeyValuePair<string, string> property in sourceTerm.LocalCustomProperties)
{
targetTerm.SetLocalCustomProperty(property.Key, property.Value);
}
}
if (targetTerm.LocalCustomProperties.Count > 0)
{
//remove properties which are not needed anymore
foreach (KeyValuePair<string, string> property in targetTerm.LocalCustomProperties)
{
if (!sourceTerm.LocalCustomProperties.Keys.Contains(property.Key, StringComparer.InvariantCultureIgnoreCase))
{
targetTerm.DeleteLocalCustomProperty(property.Key);
}
}
}
if (sourceTerm.CustomProperties.Count > 0)
{
// add properties from source
foreach (KeyValuePair<string, string> property in sourceTerm.CustomProperties)
{
targetTerm.SetCustomProperty(property.Key, property.Value);
}
}
if (targetTerm.CustomProperties.Count > 0)
{
//remove properties which are not needed anymore
foreach (KeyValuePair<string, string> property in targetTerm.CustomProperties)
{
if (!sourceTerm.CustomProperties.Keys.Contains(property.Key, StringComparer.InvariantCultureIgnoreCase))
{
targetTerm.DeleteCustomProperty(property.Key);
}
}
}
targetClientContext.ExecuteQuery();
foreach (int language in languagesToProcess)
{
ClientResult<string> targetTermDescription = sourceTerm.GetDescription(language);
sourceClientContext.ExecuteQuery();
targetTerm.SetDescription(targetTermDescription.Value, language);
//Process labels
// Add new labels if needed
LabelCollection sourceLabels = sourceTerm.GetAllLabels(language);
sourceClientContext.Load(sourceLabels);
sourceClientContext.ExecuteQuery();
LabelCollection targetLabels = targetTerm.GetAllLabels(language);
targetClientContext.Load(targetLabels);
targetClientContext.ExecuteQuery();
foreach (Label sourceLabel in sourceLabels)
{
Label test = targetLabels.FirstOrDefault<Label>(label => label.Value.Equals(sourceLabel.Value));
if (test == null)
{
targetTerm.CreateLabel(sourceLabel.Value, sourceLabel.Language, sourceLabel.IsDefaultForLanguage);
}
}
targetClientContext.ExecuteQuery();
// remove non existing labels
targetLabels = targetTerm.GetAllLabels(language);
targetClientContext.Load(targetLabels);
targetClientContext.ExecuteQuery();
List<Label> labelsToRemove = new List<Label>();
foreach (Label targetLabel in targetLabels)
{
Label test = sourceLabels.FirstOrDefault<Label>(label => label.Value.Equals(targetLabel.Value));
if (test == null)
{
labelsToRemove.Add(targetLabel);
}
}
foreach (Label label in labelsToRemove)
{
label.DeleteObject();
targetClientContext.ExecuteQuery();
}
}
// Deprecating terms on the target is tricky...this will prevent reuse of deprecited terms later on
//if (sourceTerm.IsDeprecated && !targetTerm.IsDeprecated)
//{
// targetTerm.Deprecate(true);
//.........这里部分代码省略.........
示例3: MapTermProperties
private void MapTermProperties(Term currentTerm, TaxonomyTermDefinition termModel)
{
currentTerm.SetDescription(termModel.Description, termModel.LCID);
foreach (var customProp in termModel.CustomProperties.Where(p => p.Override))
{
currentTerm.SetCustomProperty(customProp.Name, customProp.Value);
}
}