예제 #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>
        /// Gets the service provider for this item.
        /// </summary>
        public static IServiceProvider GetServiceProvider(this IVsHierarchyItem item)
        {
            Ole.IServiceProvider oleSp;
            if (item.HierarchyIdentity.IsNestedItem &&
                ErrorHandler.Succeeded(item.HierarchyIdentity.NestedHierarchy.GetSite(out oleSp)) &&
                oleSp != null)
            {
                return(new ServiceProvider(oleSp));
            }

            if (ErrorHandler.Succeeded(item.HierarchyIdentity.Hierarchy.GetSite(out oleSp)) &&
                oleSp != null)
            {
                return(new ServiceProvider(oleSp));
            }

            // Try the hierarchy root as a fallback.
            var root = item.GetRoot();

            if (root != null &&
                ErrorHandler.Succeeded(root.HierarchyIdentity.Hierarchy.GetSite(out oleSp)) &&
                oleSp != null)
            {
                return(new ServiceProvider(oleSp));
            }

            // Try the hierarchy top-most node as a fallback (this would be the solution itself)
            root = item.GetTopMost();
            if (root != null &&
                ErrorHandler.Succeeded(root.HierarchyIdentity.Hierarchy.GetSite(out oleSp)) &&
                oleSp != null)
            {
                return(new ServiceProvider(oleSp));
            }

            // Default to a global service provider provided by VS shell.
            // TODO: may require us to switch to the UI thread to get the right one.
            return(ServiceProvider.GlobalProvider);
        }
예제 #4
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="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(
            IVsHierarchyItem hierarchyNode,
            ISolutionExplorerNodeFactory nodeFactory,
            IAdapterService adapter,
            JoinableLazy <IVsUIHierarchyWindow> solutionExplorer)
            : base(SolutionNodeKind.SolutionItem, hierarchyNode, nodeFactory, adapter, solutionExplorer)
        {
            this.nodeFactory = nodeFactory;

            Item         = new Lazy <ProjectItem>(() => (ProjectItem)hierarchyNode.GetExtenderObject());
            owningFolder = new Lazy <ISolutionFolderNode>(() =>
                                                          this.nodeFactory.CreateNode(hierarchyNode.GetRoot()) as ISolutionFolderNode);
        }