Ejemplo n.º 1
0
 void ResetOwnerProject()
 {
     if (ownerProjects.Count > 0)
     {
         DocumentContext.AttachToProject(FindBestDefaultProject());
     }
 }
Ejemplo n.º 2
0
        void UpdateOwnerProjects(IEnumerable <DotNetProject> allProjects)
        {
            if (DocumentContext == null)
            {
                return;                //This can happen if this object is disposed
            }
            var projects = new HashSet <DotNetProject> (allProjects.Where(p => p.IsFileInProject(DocumentContext.Name)));

            if (ownerProjects == null || !projects.SetEquals(ownerProjects))
            {
                SetOwnerProjects(projects.OrderBy(p => p.Name).ToList());
                var dnp = DocumentContext.Project as DotNetProject;
                if (ownerProjects.Count > 0 && (dnp == null || !ownerProjects.Contains(dnp)))
                {
                    // If the project for the document is not a DotNetProject but there is a project containing this file
                    // in the current solution, then use that project
                    var pp = DocumentContext.Project != null?FindBestDefaultProject(DocumentContext.Project.ParentSolution) : null;

                    if (pp != null)
                    {
                        DocumentContext.AttachToProject(pp);
                    }
                }
            }
        }
        void UpdateOwnerProjects()
        {
            if (IdeApp.Workspace == null)
            {
                ownerProjects = new List <DotNetProject> ();
                return;
            }
            if (DocumentContext == null)
            {
                return;                //This can happen if this object is disposed
            }
            var projects = new HashSet <DotNetProject> (IdeApp.Workspace.GetAllItems <DotNetProject> ().Where(p => p.IsFileInProject(DocumentContext.Name)));

            if (ownerProjects == null || !projects.SetEquals(ownerProjects))
            {
                ownerProjects = projects.OrderBy(p => p.Name).ToList();
                var dnp = DocumentContext.Project as DotNetProject;
                if (ownerProjects.Count > 0 && (dnp == null || !ownerProjects.Contains(dnp)))
                {
                    // If the project for the document is not a DotNetProject but there is a project containing this file
                    // in the current solution, then use that project
                    var pp = DocumentContext.Project != null?ownerProjects.FirstOrDefault(p => p.ParentSolution == DocumentContext.Project.ParentSolution) : null;

                    if (pp != null)
                    {
                        DocumentContext.AttachToProject(pp);
                    }
                }
            }
            if (DocumentContext.Project == null && ownerProjects.Count > 0)
            {
                DocumentContext.AttachToProject(ownerProjects[0]);
            }
            UpdatePath();
        }
Ejemplo n.º 4
0
        void HandleStartupProjectChanged(object sender, EventArgs e)
        {
            // If the startup project changes, and the new startup project is an owner of this document,
            // then attach the document to that project

            var sol = (Projects.Solution)sender;
            var p   = sol.StartupItem as DotNetProject;

            if (p != null && ownerProjects.Contains(p))
            {
                DocumentContext.AttachToProject(p);
            }
        }
Ejemplo n.º 5
0
 void HandleWorkspaceItemUnloaded(object sender, WorkspaceItemEventArgs e)
 {
     if (ownerProjects == null)
     {
         return;
     }
     foreach (var p in e.Item.GetAllItems <DotNetProject> ())
     {
         RemoveOwnerProject(p);
     }
     if (ownerProjects.Count == 0)
     {
         ownerProjects = null;
         DocumentContext.AttachToProject(null);
     }
 }