Esempio n. 1
0
 public bool Contains(DocumentNode nodeBeingLookedFor)
 {
     for (int i = 0; i < this.nodes.Count; i++)
     {
         NodePathEntry item      = this.nodes[i];
         DocumentNode  container = item.Container;
         DocumentNode  target    = item.Target;
         if (container == nodeBeingLookedFor)
         {
             return(true);
         }
         while (target != container)
         {
             if (target == null)
             {
                 CultureInfo currentCulture = CultureInfo.CurrentCulture;
                 string      documentNodePathContainerIsNotAncestor = ExceptionStringTable.DocumentNodePathContainerIsNotAncestor;
                 object[]    name = new object[] { container.Type.Name, item.Target.Type.Name };
                 throw new InvalidOperationException(string.Format(currentCulture, documentNodePathContainerIsNotAncestor, name));
             }
             if (target == nodeBeingLookedFor)
             {
                 return(true);
             }
             target = target.Parent;
         }
     }
     return(false);
 }
Esempio n. 2
0
        public DocumentNodePath GetPathInContainer(DocumentNode node)
        {
            DocumentNodePath subpath = this.GetSubpath(this.nodes.Count - 1);
            NodePathEntry    item    = this.nodes[this.nodes.Count - 1];

            subpath.nodes.Add(new NodePathEntry(item.PropertyKey, item.Container, node, item.ViewKey));
            return(subpath);
        }
Esempio n. 3
0
        public override int GetHashCode()
        {
            int hashCode = 0;

            for (int i = 0; i < this.nodes.Count; i++)
            {
                NodePathEntry item = this.nodes[i];
                hashCode = hashCode ^ item.GetHashCode();
            }
            return(hashCode);
        }
Esempio n. 4
0
        public override string ToString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            for (int i = 0; i < this.nodes.Count; i++)
            {
                if (i > 0)
                {
                    stringBuilder.Append(',');
                }
                NodePathEntry item = this.nodes[i];
                stringBuilder.Append(item.ToString());
            }
            return(stringBuilder.ToString());
        }
Esempio n. 5
0
 public bool Equals(NodePathEntry other)
 {
     if (this.target != other.target || this.container != other.container || this.propertyKey != other.propertyKey)
     {
         return(false);
     }
     if (this.viewKey == null && other.viewKey == null)
     {
         return(true);
     }
     if (this.viewKey == null)
     {
         return(false);
     }
     return(this.viewKey.Equals(other.viewKey));
 }
Esempio n. 6
0
 public void GetPathAsNodes(List <DocumentNode> newNodeList)
 {
     newNodeList.Clear();
     for (int i = 0; i < this.nodes.Count; i++)
     {
         NodePathEntry item      = this.nodes[i];
         DocumentNode  container = item.Container;
         DocumentNode  target    = item.Target;
         int           count     = newNodeList.Count;
         while (target != container)
         {
             if (target == null)
             {
                 CultureInfo currentCulture = CultureInfo.CurrentCulture;
                 string      documentNodePathContainerIsNotAncestor = ExceptionStringTable.DocumentNodePathContainerIsNotAncestor;
                 object[]    name = new object[] { container.Type.Name, item.Target.Type.Name };
                 throw new InvalidOperationException(string.Format(currentCulture, documentNodePathContainerIsNotAncestor, name));
             }
             newNodeList.Insert(count, target);
             target = target.Parent;
         }
         newNodeList.Insert(count, container);
     }
 }