예제 #1
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="nodeFactory">The factory for child nodes.</param>
 /// <param name="adapter">The adapter service that implements the smart cast <see cref="ISolutionExplorerNode.As{T}"/>.</param>
 public ProjectItemNode(
     SolutionNodeKind kind,
     IVsHierarchyItem hierarchyNode,
     ISolutionExplorerNodeFactory nodeFactory,
     IAdapterService adapter,
     Lazy <IVsUIHierarchyWindow> solutionExplorer)
     : base(kind, hierarchyNode, nodeFactory, adapter, solutionExplorer)
 {
     this.nodeFactory = nodeFactory;
     owningProject    = new Lazy <IProjectNode>(() =>
                                                this.nodeFactory.CreateNode(hierarchyNode.GetRoot()) as IProjectNode);
 }
예제 #2
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="nodeFactory">The factory for child nodes.</param>
		/// <param name="adapter">The adapter service that implements the smart cast <see cref="ISolutionExplorerNode.As{T}"/>.</param>
		public ProjectItemNode(
			SolutionNodeKind kind,
			IVsHierarchyItem hierarchyNode,
			ISolutionExplorerNodeFactory nodeFactory,
			IAdapterService adapter,
			Lazy<IVsUIHierarchyWindow> solutionExplorer)
			: base(kind, hierarchyNode, nodeFactory, adapter, solutionExplorer)
		{
			this.nodeFactory = nodeFactory;
			owningProject = new Lazy<IProjectNode>(() => 
				this.nodeFactory.CreateNode(hierarchyNode.GetRoot ()) as IProjectNode);
		}
예제 #3
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;
			});
		}
예제 #4
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);
     });
 }
예제 #5
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));
            });
        }
예제 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SolutionExplorerNode"/> class.
        /// </summary>
        /// <param name="nodeKind">Kind of the node.</param>
        /// <param name="hierarchyItem">The underlying hierarchy represented by this node.</param>
        /// <param name="nodeFactory">The factory for child nodes.</param>
        /// <param name="adapter">The adapter service that implements the smart cast <see cref="ISolutionExplorerNode.As{T}"/>.</param>
        protected SolutionExplorerNode(
            SolutionNodeKind nodeKind,
            IVsHierarchyItem hierarchyItem,
            ISolutionExplorerNodeFactory nodeFactory,
            IAdapterService adapter,
            JoinableLazy <IVsUIHierarchyWindow> solutionExplorer)
        {
            Guard.NotNull(nameof(hierarchyItem), hierarchyItem);
            Guard.NotNull(nameof(nodeFactory), nodeFactory);
            Guard.NotNull(nameof(adapter), adapter);
            Guard.NotNull(nameof(solutionExplorer), solutionExplorer);

            this.hierarchyItem    = hierarchyItem;
            this.nodeFactory      = nodeFactory;
            this.adapter          = adapter;
            this.solutionExplorer = solutionExplorer;

            Kind   = nodeKind;
            parent = hierarchyItem.Parent == null ? new Lazy <ISolutionExplorerNode>(() => null) : new Lazy <ISolutionExplorerNode>(() => nodeFactory.CreateNode(hierarchyItem.Parent));
            name   = new Lazy <string>(() => hierarchyItem.GetProperty(VsHierarchyPropID.Name, ""));

            Func <bool> getHiddenProperty = () => this.hierarchyItem.GetProperty(VsHierarchyPropID.IsHiddenItem, false);

            isHidden = hierarchyItem.Parent != null ?
                       new Lazy <bool>(() => getHiddenProperty() || parent.Value.IsHidden) :
                       new Lazy <bool>(() => getHiddenProperty());

            solutionNode = new JoinableLazy <ISolutionNode>(async() =>
                                                            await ServiceLocator.Global.GetExport <ISolutionExplorer>().Solution);

            if (hierarchyItem.HierarchyIdentity.IsNestedItem)
            {
                hierarchy = hierarchyItem.HierarchyIdentity.NestedHierarchy;
                itemId    = hierarchyItem.HierarchyIdentity.NestedItemID;
            }
            else
            {
                hierarchy = hierarchyItem.HierarchyIdentity.Hierarchy;
                itemId    = hierarchyItem.HierarchyIdentity.ItemID;
            }
        }