本文整理汇总了C#中IPropertyBag.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# IPropertyBag.Remove方法的具体用法?C# IPropertyBag.Remove怎么用?C# IPropertyBag.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPropertyBag
的用法示例。
在下文中一共展示了IPropertyBag.Remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoBeforeUpdate
/// <summary>
/// This method is called just before a node is updated by the repository.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="node">The node which will be modified.</param>
/// <param name="modifiedProperties">The updated properties of the node.</param>
protected override void DoBeforeUpdate(IMansionContext context, Node node, IPropertyBag modifiedProperties)
{
// if the name has not changed we are not interested
string newName;
if (!modifiedProperties.TryGet(context, "name", out newName))
return;
// if the name has not changed after normalization we are not interested
newName = TagUtilities.Normalize(newName);
if (node.Pointer.Name.Equals(newName))
{
modifiedProperties.Remove("name");
return;
}
modifiedProperties.Set("name", newName);
// if the tag is renamed to another already existing tag, move all content to that existing tag and delete this one
Node existingTag;
var tagIndexNode = TagUtilities.RetrieveTagIndexNode(context);
if (TagUtilities.TryRetrieveTagNode(context, tagIndexNode, newName, out existingTag))
{
// TODO: move all content to the existing tag
// TODO: delete this tag
}
}
示例2: ToGuids
/// <summary>
/// Manages the tags.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="properties">The new properties.</param>
public static void ToGuids(IMansionContext context, IPropertyBag properties)
{
// validate arguments
if (context == null)
throw new ArgumentNullException("context");
if (properties == null)
throw new ArgumentNullException("properties");
// get the tag name string
string tagNameString;
if (!properties.TryGet(context, "_tags", out tagNameString))
return;
// normalize the tag names
var tagNames = NormalizeNames(tagNameString).ToList();
// retrieve the tag index node
var tagIndexNode = RetrieveTagIndexNode(context);
// loop over all the tag names
var tagNodes = tagNames.Select(tagName => RetrieveTagNode(context, tagIndexNode, tagName));
// set the new tag guids
properties.Set("tagGuids", string.Join(",", tagNodes.Select(x => x.PermanentId)));
properties.Remove("_tags");
}