Example #1
0
        private void HandleAddLicenseHeaderToAllFilesInProjectReturn(
            object obj,
            AddLicenseHeaderToAllFilesReturn addLicenseHeaderToAllFilesReturn)
        {
            var project     = obj as Project;
            var projectItem = obj as ProjectItem;

            if (project == null && projectItem == null)
            {
                return;
            }
            Project currentProject = project;

            if (projectItem != null)
            {
                currentProject = projectItem.ContainingProject;
            }

            if (addLicenseHeaderToAllFilesReturn.NoHeaderFound)
            {
                // No license header found...
                var solutionSearcher = new AllSolutionProjectsSearcher();
                var projects         = solutionSearcher.GetAllProjects(_dte.Solution);

                if (projects.Any(projectInSolution => LicenseHeaderFinder.GetHeaderDefinitionForProjectWithoutFallback(projectInSolution) != null))
                {
                    // If another projet has a license header, offer to add a link to the existing one.
                    if (MessageBoxHelper.DoYouWant(Resources.Question_AddExistingDefinitionFileToProject))
                    {
                        new AddExistingLicenseHeaderDefinitionFileToProjectCommand().AddDefinitionFileToOneProject(
                            currentProject.FileName,
                            currentProject.ProjectItems);

                        AddLicenseHeadersToAllFilesInProjectCallback((object)project ?? projectItem, null);
                    }
                }
                else
                {
                    // If no project has a license header, offer to add one for the solution.
                    if (MessageBoxHelper.DoYouWant(Resources.Question_AddNewLicenseHeaderDefinitionForSolution))
                    {
                        AddNewSolutionLicenseHeaderDefinitionFileCallback(this, new EventArgs());
                    }
                }
            }
        }