Microsoft.VisualStudio.Project.SolutionListenerForProjectReferenceUpdate.OnBeforeCloseProject C# (CSharp) Method

OnBeforeCloseProject() public method

Delete this project from the references of projects of this type, if it is found.
public OnBeforeCloseProject ( IVsHierarchy hierarchy, int removed ) : int
hierarchy IVsHierarchy
removed int
return int
        public override int OnBeforeCloseProject(IVsHierarchy hierarchy, int removed)
        {
            if(removed != 0)
            {
                List<ProjectReferenceNode> projectReferences = this.GetProjectReferencesContainingThisProject(hierarchy);

                foreach(ProjectReferenceNode projectReference in projectReferences)
                {
                    projectReference.Remove(false);
                    // Set back the remove state on the project refererence. The reason why we are doing this is that the OnBeforeUnloadProject immedaitely calls
                    // OnBeforeCloseProject, thus we would be deleting references when we should not. Unload should not remove references.
                    projectReference.CanRemoveReference = true;
                }
            }

            return VSConstants.S_OK;
        }