public ProjectItemContainerNode(IProjectNode node, Lazy <ISolutionExplorerNodeFactory> nodeFactory) : this( node, nodeFactory, new Lazy <IVsHierarchyItem>(() => node.AsVsHierarchyItem()), new Lazy <ProjectItems>(() => node.AsVsHierarchyItem().GetExtenderObject <Project>().ProjectItems)) { }
public void AddReference(IProjectNode referencedProject) { if (referencedProject.Supports(KnownCapabilities.SharedAssetsProject)) { var sharedProjectReferencesHelper = hierarchyNode.Value .GetServiceProvider() .GetService <SVsSharedProjectReferencesHelper, IVsSharedProjectReferencesHelper>(); sharedProjectReferencesHelper.ChangeSharedProjectReferences( node.AsVsHierarchy(), 0, null, 1, new object[] { referencedProject.AsVsHierarchy() }); sharedProjectReferencesHelper.ChangeSharedMSBuildFileImports( node.AsVsHierarchy(), new[] { referencedProject.PhysicalPath }, new[] { Path.ChangeExtension(referencedProject.PhysicalPath, ".projitems") }, "Shared" ); } else { var automationReferencedProject = referencedProject.AsVsHierarchyItem().GetExtenderObject() as Project; if (automationReferencedProject == null) { throw new NotSupportedException(Strings.ProjectNode.AddProjectReferenceNotSupported(referencedProject.Name)); } var langProject = node.AsVsLangProject(); if (langProject == null) { throw new NotSupportedException(Strings.ProjectNode.AddProjectReferenceNotSupported(node.Name)); } langProject.References.AddProject(automationReferencedProject); var reference = langProject .References .OfType <Reference>() .Where(x => x.Name == referencedProject.Name) .FirstOrDefault(); if (reference == null) { throw new InvalidOperationException( Strings.ProjectNode.AddProjectReferenceFailed(referencedProject.Name, node.Name)); } } }
public ReferenceContainerNode(IProjectNode node) { this.node = node; hierarchyNode = new Lazy <IVsHierarchyItem>(() => node.AsVsHierarchyItem()); }