private void Get(ICatalogueElement element, IList searchResults) { // Check the element itself. if (_filter.IsMatch(element)) { searchResults.Add(element); } if (_options.Recursive) { // Check children. if ((_filter.Elements & (CatalogueElements.Namespace | CatalogueElements.Source)) != CatalogueElements.None) { var namespaceParent = element as INamespaceParent; if (namespaceParent != null) { foreach (Namespace ns in namespaceParent.Namespaces) { Get(ns, searchResults); } } } if ((_filter.Elements & CatalogueElements.Source) != CatalogueElements.None) { var sourceParent = element as ISourceParent; if (sourceParent != null) { foreach (Source source in sourceParent.Sources) { Get(source, searchResults); } } } var catalogue = element as Catalogue; if (catalogue != null) { if ((_filter.Elements & CatalogueElements.Event) != CatalogueElements.None) { foreach (EventType eventType in catalogue.EventTypes) { Get(eventType, searchResults); } } } } }
private bool IsNamesMatch(ICatalogueElement element) { // Only have to check if there is a filter. if (m_elementReferencePattern != null) { Debug.Assert(m_elementReferenceRegex != null, "m_elementReferenceRegex is null - Prepare()" + " not called?"); IElementReference referencedElement = element as IElementReference; if (referencedElement != null && !m_elementReferenceRegex.IsMatch(referencedElement.FullyQualifiedReference)) { return(false); } } return(true); }
internal bool IsMatch(ICatalogueElement element) { // Check the element. if ((m_elementFilter & element.Element) == CatalogueElements.None) { return(false); } // Check the names. if (!IsNamesMatch(element)) { return(false); } return(true); }
internal Searcher(ICatalogueElement searchRoot) { _searchRoot = searchRoot; _filter = new SearchFilter(); _options = new SearchOptions(); }
public bool Contains(ICatalogueElement element) { return(m_list.Contains(element)); }