public override int CompareTo(object obj) { if (obj == null) { return(1); } BinaryOperation other = obj as BinaryOperation; return(this.Left.CompareTo(other.Left) * 10 + this.Right.CompareTo(other.Right)); }
// override object.Equals public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return(false); } BinaryOperation other = obj as BinaryOperation; return(other.Left == this.Left && other.Right == this.Right); }
protected IEnumerable <Proposition> Plainify(Proposition prop, string type = null) { List <Proposition> result = new List <Proposition>(); if (prop is BinaryOperation) { if (type == null) { type = prop.GetType().Name; } if (prop.GetType().Name.Equals(type)) { BinaryOperation binary = prop as BinaryOperation; result.AddRange(Plainify(binary.Left)); result.AddRange(Plainify(binary.Right)); return(result); } } // else: result.Add(prop); return(result); }