Beispiel #1
0
 private static void UpdateNameScopes(DocumentNode parent, IProperty propertyKey, DocumentNode node, bool adding)
 {
     if (parent == null)
     {
         return;
     }
     if (node is DocumentPrimitiveNode)
     {
         if (propertyKey == null || !parent.IsNameProperty((IPropertyId)propertyKey))
         {
             return;
         }
         DocumentNodeNameScope containingNameScope = parent.FindContainingNameScope();
         if (containingNameScope == null)
         {
             return;
         }
         string valueAsString = DocumentPrimitiveNode.GetValueAsString(node);
         if (valueAsString == null)
         {
             return;
         }
         if (adding)
         {
             containingNameScope.AddNode(valueAsString, parent);
         }
         else
         {
             containingNameScope.RemoveNode(valueAsString);
         }
     }
     else
     {
         DocumentNodeNameScope containingNameScope = node.FindContainingNameScope();
         if (containingNameScope == null)
         {
             return;
         }
         DocumentNode.UpdateNameScopesRecursive(containingNameScope, node, adding);
     }
 }