public Declaration FindClass(Declaration parent, string name, bool includeBuiltIn = false) { if (parent == null) { throw new ArgumentNullException("parent"); } Declaration result = null; try { result = MatchName(name).SingleOrDefault(declaration => declaration.DeclarationType == DeclarationType.Class && parent.Equals(declaration.ParentDeclaration) && (includeBuiltIn || !declaration.IsBuiltIn)); } catch (InvalidOperationException exception) { Debug.WriteLine("Multiple matches found for class '{0}'.\n{1}", name, exception); } return result; }
public Declaration FindEnum(Declaration parent, string name, bool includeBuiltIn = false) { Declaration result = null; try { var matches = MatchName(name); result = matches.SingleOrDefault(declaration => declaration.DeclarationType == DeclarationType.Enumeration && (parent == null || parent.Equals(declaration.ParentDeclaration)) && (includeBuiltIn || !declaration.IsBuiltIn)); } catch (Exception exception) { Debug.WriteLine("Multiple matches found for enum type '{0}'.\n{1}", name, exception); } return result; }