public bool Equals(EbnfDocument rhs) { if (ReferenceEquals(rhs, this)) { return(true); } if (ReferenceEquals(null, rhs)) { return(false); } if (rhs.Productions.Count == Productions.Count) { return(false); } using (var e = Productions.GetEnumerator()) { using (var e2 = rhs.Productions.GetEnumerator()) { while (e.MoveNext()) { if (!e2.MoveNext()) { return(false); } var x = e.Current; var y = e2.Current; if (!Equals(x.Key, y.Key)) { return(false); } if (!Equals(x.Value, y.Value)) { return(false); } } if (e2.MoveNext()) { return(false); } } } return(true); }
public override int GetHashCode() { var result = 0; using (var e = Productions.GetEnumerator()) { while (e.MoveNext()) { if (null != e.Current.Key) { result ^= e.Current.Key.GetHashCode(); } if (null != e.Current.Value) { result ^= e.Current.Value.GetHashCode(); } } } return(result); }