private static ISet<string> GetNames(Declaration declaration, Predicate<Declaration> predicate)
        {
            var set = new HashSet<string>();
            var stack = new Stack<Declaration>();
            stack.Push(declaration);

            while (stack.Count > 0)
            {
                var current = stack.Pop();
                if (current == null)
                {
                    continue;
                }

                if (predicate(current))
                {
                    set.Add(current.Name);
                }

                foreach (var child in current.Children)
                {
                    stack.Push(child);
                }
            }

            return SpecializedCollections.ReadOnlySet(set);
        }
예제 #2
0
 private static ISet<string> GetTypeNames(Declaration declaration)
 {
     return GetNames(declaration, s_isTypePredicate);
 }
 private static ISet<string> GetNamespaceNames(Declaration declaration)
 {
     return GetNames(declaration, IsNamespacePredicate);
 }
예제 #4
0
 private static ISet <string> GetTypeNames(Declaration declaration)
 {
     return(GetNames(declaration, s_isTypePredicate));
 }