public Class FindClass(string name, StringComparison stringComparison = StringComparison.Ordinal) { if (string.IsNullOrEmpty(name)) { return(null); } var entries = name.Split(new[] { "::" }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (entries.Count <= 1) { return(Classes.Find(e => e.Name.Equals(name, stringComparison))); } var className = entries[entries.Count - 1]; var namespaces = entries.Take(entries.Count - 1); DeclarationContext declContext = FindNamespace(namespaces); if (declContext == null) { declContext = FindClass(entries[0]); if (declContext == null) { return(null); } } return(declContext.FindClass(className)); }
public Class FindClass(string name, StringComparison stringComparison = StringComparison.Ordinal) { if (string.IsNullOrEmpty(name)) { return(null); } var entries = name.Split(new[] { "::" }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (entries.Count <= 1) { var @class = Classes.Find(c => c.Name.Equals(name, stringComparison)) ?? Namespaces.Select(n => n.FindClass(name, stringComparison)).FirstOrDefault(c => c != null); if (@class != null) { return(@class.CompleteDeclaration == null ? @class : (Class)@class.CompleteDeclaration); } return(null); } var className = entries[entries.Count - 1]; var namespaces = entries.Take(entries.Count - 1); DeclarationContext declContext = FindDeclaration(namespaces); if (declContext == null) { declContext = FindClass(entries[0]); if (declContext == null) { return(null); } } return(declContext.FindClass(className)); }