예제 #1
0
 public CustomSolutionNode(IVsSolutionHierarchyNode node,
                           Lazy <ITreeNode> parent,
                           ITreeNodeFactory <IVsSolutionHierarchyNode> nodeFactory,
                           IAdapterService adapterService)
     : base(SolutionNodeKind.Custom, node, parent, nodeFactory, adapterService)
 {
 }
예제 #2
0
 public ItemProperties(ItemNode item)
 {
     this.node = item.HierarchyNode;
     this.item = item.HierarchyNode.ExtensibilityObject as ProjectItem;
     this.msBuild = item.HierarchyNode.VsHierarchy as IVsBuildPropertyStorage;
     if (System.Diagnostics.Debugger.IsAttached)
         debugString = string.Join(Environment.NewLine, GetDynamicMemberNames()
             .Select(name => name + "=" + GetValue(name)));
 }
예제 #3
0
 public ItemProperties(ItemNode item)
 {
     this.node    = item.HierarchyNode;
     this.item    = item.HierarchyNode.ExtensibilityObject as ProjectItem;
     this.msBuild = item.HierarchyNode.VsHierarchy as IVsBuildPropertyStorage;
     if (System.Diagnostics.Debugger.IsAttached)
     {
         debugString = string.Join(Environment.NewLine, GetDynamicMemberNames()
                                   .Select(name => name + "=" + GetValue(name)));
     }
 }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReferencesNode"/> class.
        /// </summary>
        /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param>
        /// <param name="parentNode">The parent node accessor.</param>
        /// <param name="nodeFactory">The factory for child nodes.</param>
        /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param>
        public ReferencesNode(
            IVsSolutionHierarchyNode hierarchyNode,
            Lazy <ITreeNode> parentNode,
            ITreeNodeFactory <IVsSolutionHierarchyNode> nodeFactory,
            IAdapterService adapter)
            : base(SolutionNodeKind.ReferencesFolder, hierarchyNode, parentNode, nodeFactory, adapter)
        {
            Guard.NotNull(() => parentNode, parentNode);

            this.References = new Lazy <References>(() =>
                                                    ((VSProject)((Project)hierarchyNode.VsHierarchy.Properties(VSConstants.VSITEMID_ROOT).ExtenderObject).Object).References);
        }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FolderNode"/> class.
        /// </summary>
        /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param>
        /// <param name="parentNode">The parent node accessor.</param>
        /// <param name="nodeFactory">The factory for child nodes.</param>
        /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param>
        public FolderNode(
            IVsSolutionHierarchyNode hierarchyNode,
            Lazy <ITreeNode> parentNode,
            ITreeNodeFactory <IVsSolutionHierarchyNode> nodeFactory,
            IAdapterService adapter)
            : base(SolutionNodeKind.Folder, hierarchyNode, parentNode, nodeFactory, adapter)
        {
            Guard.NotNull(() => parentNode, parentNode);

            this.Folder = new Lazy <EnvDTE.ProjectItem>(
                () => (EnvDTE.ProjectItem)hierarchyNode.VsHierarchy.Properties(hierarchyNode.ItemId).ExtenderObject);
        }
예제 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReferenceNode"/> class.
        /// </summary>
        /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param>
        /// <param name="parentNode">The parent node accessor.</param>
        /// <param name="nodeFactory">The factory for child nodes.</param>
        /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param>
        public ReferenceNode(
            IVsSolutionHierarchyNode hierarchyNode,
            Lazy <ITreeNode> parentNode,
            ITreeNodeFactory <IVsSolutionHierarchyNode> nodeFactory,
            IAdapterService adapter)
            : base(SolutionNodeKind.Reference, hierarchyNode, parentNode, nodeFactory, adapter)
        {
            Guard.NotNull(() => parentNode, parentNode);

            this.Reference = new Lazy <VSLangProj.Reference>(
                () => (VSLangProj.Reference)hierarchyNode.VsHierarchy.Properties(hierarchyNode.ItemId).ExtenderObject);
        }
        private ISolutionExplorerNode CreateNode(IVsSolutionHierarchyNode hierarchyNode)
        {
            Func<IVsSolutionHierarchyNode, Lazy<ITreeNode>> getParent = null;
            Func<IVsSolutionHierarchyNode, ITreeNode> getNode = null;

            getParent = hierarchy => hierarchy.Parent == null ? null :
                new Lazy<ITreeNode>(() => this.nodeFactory.Value.CreateNode(getParent(hierarchy.Parent), hierarchy.Parent));

            getNode = hierarchy => hierarchy == null ? null :
                this.nodeFactory.Value.CreateNode(getParent(hierarchy), hierarchy);

            return getNode(hierarchyNode) as ISolutionExplorerNode;
        }
        private ISolutionExplorerNode CreateNode(IVsSolutionHierarchyNode hierarchyNode)
        {
            Func <IVsSolutionHierarchyNode, Lazy <ITreeNode> > getParent = null;
            Func <IVsSolutionHierarchyNode, ITreeNode>         getNode   = null;

            getNode = hierarchy => hierarchy == null ? null :
                      this.nodeFactory.Value.CreateNode(getParent(hierarchy), hierarchy);

            getParent = hierarchy => hierarchy.Parent == null ? null :
                        new Lazy <ITreeNode>(() => this.nodeFactory.Value.CreateNode(getParent(hierarchy.Parent), hierarchy.Parent));

            return(getNode(hierarchyNode) as ISolutionExplorerNode);
        }
예제 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectNode"/> class.
        /// </summary>
        /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param>
        /// <param name="parentNode">The parent node accessor.</param>
        /// <param name="nodeFactory">The factory for child nodes.</param>
        /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param>
        public ProjectNode(
            IVsSolutionHierarchyNode hierarchyNode,
            Lazy <ITreeNode> parentNode,
            ITreeNodeFactory <IVsSolutionHierarchyNode> nodeFactory,
            IAdapterService adapter)
            : base(SolutionNodeKind.Project, hierarchyNode, parentNode, nodeFactory, adapter)
        {
            Guard.NotNull(() => parentNode, parentNode);

            this.Project       = new Lazy <EnvDTE.Project>(() => (EnvDTE.Project)hierarchyNode.VsHierarchy.Properties(hierarchyNode.ItemId).ExtenderObject);
            this.properties    = new Lazy <GlobalProjectProperties>(() => new GlobalProjectProperties(this));
            this.Configuration = new ProjectConfiguration(this);
        }
예제 #10
0
		/// <summary>
		/// Initializes a new instance of the <see cref="ProjectItemNode"/> class.
		/// </summary>
		/// <param name="kind">The kind of project node.</param>
		/// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param>
		/// <param name="parentNode">The parent node accessor.</param>
		/// <param name="nodeFactory">The factory for child nodes.</param>
		/// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param>
		public ProjectItemNode(
			SolutionNodeKind kind,
			IVsSolutionHierarchyNode hierarchyNode,
			Lazy<ITreeNode> parentNode,
			ITreeNodeFactory<IVsSolutionHierarchyNode> nodeFactory,
			IAdapterService adapter)
			: base(kind, hierarchyNode, parentNode, nodeFactory, adapter)
		{
			this.nodeFactory = nodeFactory;
			this.owningProject = new Lazy<IProjectNode>(() =>
			{
				var owningHierarchy = new VsSolutionHierarchyNode(hierarchyNode.VsHierarchy, VSConstants.VSITEMID_ROOT);
				return this.nodeFactory.CreateNode(GetParent(owningHierarchy), owningHierarchy) as IProjectNode;
			});
		}
예제 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProjectItemNode"/> class.
 /// </summary>
 /// <param name="kind">The kind of project node.</param>
 /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param>
 /// <param name="parentNode">The parent node accessor.</param>
 /// <param name="nodeFactory">The factory for child nodes.</param>
 /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param>
 public ProjectItemNode(
     SolutionNodeKind kind,
     IVsSolutionHierarchyNode hierarchyNode,
     Lazy <ITreeNode> parentNode,
     ITreeNodeFactory <IVsSolutionHierarchyNode> nodeFactory,
     IAdapterService adapter)
     : base(kind, hierarchyNode, parentNode, nodeFactory, adapter)
 {
     this.nodeFactory   = nodeFactory;
     this.owningProject = new Lazy <IProjectNode>(() =>
     {
         var owningHierarchy = new VsSolutionHierarchyNode(hierarchyNode.VsHierarchy, VSConstants.VSITEMID_ROOT);
         return(this.nodeFactory.CreateNode(GetParent(owningHierarchy), owningHierarchy) as IProjectNode);
     });
 }
예제 #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SolutionTreeNode"/> class.
        /// </summary>
        /// <param name="nodeKind">Kind of the node.</param>
        /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param>
        /// <param name="parentNode">The parent node accessor.</param>
        /// <param name="nodeFactory">The factory for child nodes.</param>
        /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param>
        protected SolutionTreeNode(
            SolutionNodeKind nodeKind,
            IVsSolutionHierarchyNode hierarchyNode,
            Lazy <ITreeNode> parentNode,
            ITreeNodeFactory <IVsSolutionHierarchyNode> nodeFactory,
            IAdapterService adapter)
        {
            Guard.NotNull(() => hierarchyNode, hierarchyNode);
            Guard.NotNull(() => nodeFactory, nodeFactory);
            Guard.NotNull(() => adapter, adapter);

            this.hierarchyNode = hierarchyNode;
            this.factory       = nodeFactory;
            this.adapter       = adapter;
            this.window        = new Lazy <IVsUIHierarchyWindow>(() => GetWindow(this.hierarchyNode.ServiceProvider));
            this.parent        = parentNode ?? new Lazy <ITreeNode>(() => null);
            this.DisplayName   = this.hierarchyNode.VsHierarchy.Properties(hierarchyNode.ItemId).DisplayName;
            this.Kind          = nodeKind;

            Func <bool> getHiddenProperty = () => GetProperty <bool?>(
                this.hierarchyNode.VsHierarchy,
                __VSHPROPID.VSHPROPID_IsHiddenItem,
                this.hierarchyNode.ItemId).GetValueOrDefault();

            this.isHidden = parentNode != null ?
                            new Lazy <bool>(() => getHiddenProperty() || parentNode.Value.IsHidden) :
                            new Lazy <bool>(() => getHiddenProperty());

            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.debuggerDisplay = BuildDebuggerDisplay();
            }

            this.solutionNode = new Lazy <ISolutionNode>(() =>
            {
                var solutionHierarchy = new VsSolutionHierarchyNode(
                    (IVsHierarchy)this.hierarchyNode.ServiceProvider.GetService <SVsSolution, IVsSolution>(),
                    VSConstants.VSITEMID_ROOT);

                return((ISolutionNode)this.factory.CreateNode(null, solutionHierarchy));
            });
        }
예제 #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SolutionItemNode"/> class.
        /// </summary>
        /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param>
        /// <param name="parentNode">The parent node accessor.</param>
        /// <param name="nodeFactory">The factory for child nodes.</param>
        /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param>
        public SolutionItemNode(
            IVsSolutionHierarchyNode hierarchyNode,
            Lazy <ITreeNode> parentNode,
            ITreeNodeFactory <IVsSolutionHierarchyNode> nodeFactory,
            IAdapterService adapter)
            : base(SolutionNodeKind.SolutionItem, hierarchyNode, parentNode, nodeFactory, adapter)
        {
            Guard.NotNull(() => parentNode, parentNode);

            this.nodeFactory = nodeFactory;

            this.Item = new Lazy <EnvDTE.ProjectItem>(
                () => (EnvDTE.ProjectItem)hierarchyNode.VsHierarchy.Properties(hierarchyNode.ItemId).ExtenderObject);

            this.owningFolder = new Lazy <ISolutionFolderNode>(() =>
            {
                var owningHierarchy = new VsSolutionHierarchyNode(hierarchyNode.VsHierarchy, VSConstants.VSITEMID_ROOT);
                return(this.nodeFactory.CreateNode(GetParent(owningHierarchy), owningHierarchy) as ISolutionFolderNode);
            });
        }
예제 #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SolutionNode"/> class.
 /// </summary>
 /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param>
 /// <param name="childNodeFactory">The factory for child nodes.</param>
 /// <param name="looseNodeFactory">The explorer node factory used to create "loose" nodes from solution explorer.</param>
 /// <param name="locator">The service locator.</param>
 /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param>
 /// <param name="solutionEvents">The solution events.</param>
 /// <param name="uiThread">The UI thread.</param>
 public SolutionNode(
     IVsSolutionHierarchyNode hierarchyNode,
     // This is the regular node factory for trees, that receives a lazy
     // pointer to the parent tree node.
     ITreeNodeFactory <IVsSolutionHierarchyNode> childNodeFactory,
     // This factory is used to create "loose" nodes from solution explorer
     ISolutionExplorerNodeFactory looseNodeFactory,
     IServiceLocator locator,
     IAdapterService adapter,
     ISolutionEvents solutionEvents,
     // Retrieving current selection must be done on the UI thread.
     IUIThread uiThread)
     : base(SolutionNodeKind.Solution, hierarchyNode, null, childNodeFactory, adapter)
 {
     this.Solution            = new Lazy <EnvDTE.Solution>(() => hierarchyNode.ServiceProvider.GetService <EnvDTE.DTE>().Solution);
     this.nodeFactory         = childNodeFactory;
     this.explorerNodeFactory = looseNodeFactory;
     this.events    = solutionEvents;
     this.selection = new Lazy <IVsMonitorSelection>(() => locator.GetService <SVsShellMonitorSelection, IVsMonitorSelection>());
     this.uiThread  = uiThread;
 }
예제 #15
0
		private Lazy<ITreeNode> GetParent(IVsSolutionHierarchyNode hierarchy)
		{
			return hierarchy.Parent == null ? null :
			   new Lazy<ITreeNode>(() => this.nodeFactory.CreateNode(GetParent(hierarchy.Parent), hierarchy.Parent));
		}
 public ISolutionExplorerNode Create(IVsSolutionHierarchyNode hierarchyNode)
 {
     return CreateNode(hierarchyNode);
 }
예제 #17
0
 private ITreeNode GetNode(IVsSolutionHierarchyNode hierarchy)
 {
     return hierarchy == null ? null :
         this.nodeFactory.Value.CreateNode(GetParent(hierarchy), hierarchy);
 }
예제 #18
0
        public ISolutionExplorerNode Create(IVsSolutionHierarchyNode hierarchyNode)
        {
            var cacheKey = Tuple.Create(hierarchyNode.VsHierarchy, hierarchyNode.ItemId);

            return nodeCache.GetOrAdd(cacheKey, _ => CreateNode(hierarchyNode));
        }
        public ISolutionExplorerNode Create(IVsSolutionHierarchyNode hierarchyNode)
        {
            var cacheKey = Tuple.Create(hierarchyNode.VsHierarchy, hierarchyNode.ItemId);

            return(nodeCache.GetOrAdd(cacheKey, _ => CreateNode(hierarchyNode)));
        }
예제 #20
0
 /// <summary>
 /// Creates a new child node using the node factory received in the constructor.
 /// </summary>
 /// <param name="hierarchyNode">The hierarchy node to create the child node for.</param>
 /// <remarks>
 /// This method is used for example when the node exposes child node creation APIs, such as
 /// the <see cref="FolderNode"/>.
 /// </remarks>
 protected virtual ITreeNode CreateNode(IVsSolutionHierarchyNode hierarchyNode)
 {
     return(this.factory.CreateNode(new Lazy <ITreeNode>(() => this), hierarchyNode));
 }
예제 #21
0
 private ITreeNode GetNode(IVsSolutionHierarchyNode hierarchy)
 {
     return(hierarchy == null ? null :
            this.nodeFactory.Value.CreateNode(GetParent(hierarchy), hierarchy));
 }
예제 #22
0
 private Lazy <ITreeNode> GetParent(IVsSolutionHierarchyNode hierarchy)
 {
     return(hierarchy.Parent == null ? null :
            new Lazy <ITreeNode>(() => this.nodeFactory.CreateNode(GetParent(hierarchy.Parent), hierarchy.Parent)));
 }