コード例 #1
0
        protected override bool TryGetItemByName(string name, out EnvDTE.CodeElement element)
        {
            var node = LookupNode();

            // Inherits statements
            foreach (var child in CodeModelService.GetInheritsNodes(node))
            {
                CodeModelService.GetInheritsNamespaceAndOrdinal(node, child, out var childName, out var ordinal);
                if (childName == name)
                {
                    element = FileCodeModel.GetOrCreateCodeElement <EnvDTE.CodeElement>(child);
                    return(true);
                }
            }

            // Implements statements
            foreach (var child in CodeModelService.GetImplementsNodes(node))
            {
                CodeModelService.GetImplementsNamespaceAndOrdinal(node, child, out var childName, out var ordinal);
                if (childName == name)
                {
                    element = FileCodeModel.GetOrCreateCodeElement <EnvDTE.CodeElement>(child);
                    return(true);
                }
            }

            element = null;
            return(false);
        }