1 using System.Collections;
2 using System.Collections.Generic;
5 namespace Pithos.Client.WPF.Utils
7 public class Node<T> : IEnumerable<Node<T>>
9 public string Path { get; set; }
11 public T Data { get; set; }
13 private List<Node<T>> _children = new List<Node<T>>();
14 public List<Node<T>> Children
16 get { return _children; }
17 set { _children = value; }
20 public IEnumerator<Node<T>> GetEnumerator()
23 foreach (var children in _children)
24 foreach (var info in children)
30 IEnumerator IEnumerable.GetEnumerator()
32 return GetEnumerator();
35 public override int GetHashCode()
37 return Path.GetHashCode();
40 public override bool Equals(object obj)
42 if (!(obj is Node<T>))
44 var other = (Node<T>) obj;
45 if (Path != other.Path)
47 if (Data==null ^ other.Data==null)
50 if (Data!=null && !Data.Equals(other.Data))
52 var thisEnum=GetEnumerator();
53 var otherEnum = other.GetEnumerator();
54 //Skipt the first item, it is the current node itself
59 var thisMove=thisEnum.MoveNext();
60 var otherMove=otherEnum.MoveNext();
62 if (thisMove ^ otherMove)
67 if (!thisEnum.Current.Equals(otherEnum.Current))