Ejemplo n.º 1
0
        private static void UpdateNameScopesRecursive(DocumentNodeNameScope nameScope, DocumentNode node, bool adding)
        {
            if (node.Name != null)
            {
                if (adding)
                {
                    nameScope.AddNode(node.Name, node);
                }
                else
                {
                    nameScope.RemoveNode(node.Name);
                }
            }
            if (node.NameScope != null)
            {
                return;
            }
            DocumentCompositeNode documentCompositeNode = node as DocumentCompositeNode;

            if (documentCompositeNode == null)
            {
                return;
            }
            if (documentCompositeNode.SupportsChildren)
            {
                for (int index = 0; index < documentCompositeNode.Children.Count; ++index)
                {
                    DocumentNode.UpdateNameScopesRecursive(nameScope, documentCompositeNode.Children[index], adding);
                }
            }
            for (int index = 0; index < documentCompositeNode.Properties.Count; ++index)
            {
                DocumentNode.UpdateNameScopesRecursive(nameScope, documentCompositeNode.Properties[index], adding);
            }
        }
Ejemplo n.º 2
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);
     }
 }