Microsoft.VisualStudio.Project.NestedProjectNode.AddVirtualProject C# (CSharp) Method

AddVirtualProject() public method

Links a nested project as a virtual project to the solution.
public AddVirtualProject ( ) : void
return void
        public virtual void AddVirtualProject()
        {
            // This is the second step in creating and adding a nested project. The inner hierarchy must have been
            // already initialized at this point.
            #region precondition
            if (this.nestedHierarchy == null)
            {
                throw new InvalidOperationException();
            }
            #endregion
            // get the IVsSolution interface from the global service provider
            IVsSolution solution = this.GetService(typeof(IVsSolution)) as IVsSolution;
            Debug.Assert(solution != null, "Could not get the IVsSolution object from the services exposed by this project");
            if (solution == null)
            {
                throw new InvalidOperationException();
            }

            this.InitializeInstanceGuid();

            // Add virtual project to solution.
            ErrorHandler.ThrowOnFailure(solution.AddVirtualProjectEx(this.nestedHierarchy, this.VirtualProjectFlags, ref this.projectInstanceGuid));

            // Now set up to listen on file changes on the nested project node.
            this.ObserveNestedProjectFile();
        }

Usage Example

Esempio n. 1
0
 /// <summary>
 /// Links the nested project nodes to the solution. The default implementation parses all nested project nodes and calles AddVirtualProjectEx on them.
 /// </summary>
 protected virtual void AddVirtualProjects()
 {
     for (HierarchyNode child = this.FirstChild; child != null; child = child.NextSibling)
     {
         NestedProjectNode nestedProjectNode = child as NestedProjectNode;
         if (nestedProjectNode != null)
         {
             nestedProjectNode.AddVirtualProject();
         }
     }
 }
All Usage Examples Of Microsoft.VisualStudio.Project.NestedProjectNode::AddVirtualProject