public CodeExplorerComponentViewModel(CodeExplorerItemViewModel parent, Declaration declaration, IEnumerable <Declaration> declarations, IProjectsProvider projectsProvider) { Parent = parent; Declaration = declaration; _projectsProvider = projectsProvider; _icon = Icons.ContainsKey(DeclarationType) ? Icons[DeclarationType] : GetImageSource(CodeExplorerUI.status_offline); Items = declarations.GroupBy(item => item.Scope).SelectMany(grouping => grouping.Where(item => item.ParentDeclaration != null && item.ParentScope == declaration.Scope && MemberTypes.Contains(item.DeclarationType)) .OrderBy(item => item.QualifiedSelection.Selection.StartLine) .Select(item => new CodeExplorerMemberViewModel(this, item, grouping))) .ToList <CodeExplorerItemViewModel>(); _name = DeclarationType == DeclarationType.ResFile && string.IsNullOrEmpty(Declaration.IdentifierName) ? CodeExplorerUI.CodeExplorer_ResourceFileText : Declaration.IdentifierName; var qualifiedModuleName = declaration.QualifiedName.QualifiedModuleName; try { switch (qualifiedModuleName.ComponentType) { case ComponentType.Document: var component = _projectsProvider.Component(qualifiedModuleName); string parenthesizedName; using (var properties = component.Properties) { parenthesizedName = properties["Name"].Value.ToString() ?? string.Empty; } if (ContainsBuiltinDocumentPropertiesProperty()) { CodeExplorerItemViewModel node = this; while (node.Parent != null) { node = node.Parent; } ((CodeExplorerProjectViewModel)node).SetParenthesizedName(parenthesizedName); } else { _name += " (" + parenthesizedName + ")"; } break; case ComponentType.ResFile: var fileName = Declaration.IdentifierName.Split('\\').Last(); _name = $"{CodeExplorerUI.CodeExplorer_ResourceFileText} ({fileName})"; break; case ComponentType.RelatedDocument: _name = $"({Declaration.IdentifierName.Split('\\').Last()})"; break; default: _name = Declaration.IdentifierName; break; } } catch { // gotcha! (this means that the property either doesn't exist or we weren't able to get it for some reason) } }