// override object.Equals public override bool Equals(object obj) { // // See the full list of guidelines at // http://go.microsoft.com/fwlink/?LinkID=85237 // and also the guidance for operator== at // http://go.microsoft.com/fwlink/?LinkId=85238 // if (obj == null || GetType() != obj.GetType()) { return(false); } StatementParent parent = (StatementParent)obj; if (Statements.SequenceEqual(parent.Statements) == false) { return(false); } if (StatementBase.Equals(Delimiter, parent.Delimiter) == false) { return(false); } return(true); }
/// <summary> /// Checks that a first parent contains a statement of a certain type /// </summary> /// <param name="parents">The parents</param> /// <typeparam name="TStatement">The statement type</typeparam> /// <returns>True if a statement of type was found, otherwise false</returns> public static bool FirstParentIsOfType <TStatement>(this IEnumerable <StatementParent> parents) where TStatement : StatementBase { if (parents.Count() == 0) { return(false); } StatementParent firstParent = parents.Last(); return(firstParent.Statements.Count(p => p.GetType().Equals(typeof(TStatement))) > 0); }