本文整理汇总了C#中Term.DeleteCustomProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Term.DeleteCustomProperty方法的具体用法?C# Term.DeleteCustomProperty怎么用?C# Term.DeleteCustomProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Term
的用法示例。
在下文中一共展示了Term.DeleteCustomProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
//.........这里部分代码省略.........