Ejemplo n.º 1
0
        public void Execute(CommandAction action)
        {
            if (SelectedProject == null)
            {
                return;
            }


            var allProjectReferences = Crawler.FindProjectDependencies(SelectedProject.FullName, SolutionName);
            var foundProjects        = allProjectReferences as IList <Dependency.Project> ?? allProjectReferences.ToList();
            var projectReferences    = foundProjects.Where(project => project.DependencyType == DependencyType.ProjectReference);
            // var assemblyReferences = allProjectReferences.Where(project => project.DependencyType == DependencyType.AssemblyReference);

            var references = projectReferences as IList <Dependency.Project> ?? projectReferences.ToList();

            switch (action)
            {
            case CommandAction.Enable:
                const string enableMessage = "Following project dependencies have been found...LINQBridge them? (Recommended)";
                PackageConfigurator.EnableProject(SelectedProjectOutputPath, SelectedAssemblyName, SolutionName);
                var enabledDependencies = new List <string>();
                enabledDependencies.Insert(0, SelectedAssemblyName);

                if (references.Any(project => PackageConfigurator.IsBridgeDisabled(project.AssemblyName, SolutionName)))
                {
                    var projectDependencies = new ProjectDependencies(references, enableMessage);
                    var dependencies        = projectDependencies.ShowDependencies(PackageConfigurator.EnableProject);
                    enabledDependencies.AddRange(dependencies.Select(project => project.AssemblyName));
                }

                MessageBox.Show(string.Format("LINQBridge on {0} has been Enabled...", string.Join(", ", enabledDependencies)), "Success", MessageBoxButtons.OK);

                break;

            case CommandAction.Disable:
                const string disableMessage = "Following project dependencies have been found...Un-LINQBridge them? (Recommended)";

                PackageConfigurator.DisableProject(SelectedProjectOutputPath, SelectedAssemblyName, SolutionName);
                var disableDependencies = new List <string>();
                disableDependencies.Insert(0, SelectedAssemblyName);

                if (references.Any(project => PackageConfigurator.IsBridgeEnabled(project.AssemblyName, SolutionName)))
                {
                    var projectDependencies = new ProjectDependencies(references, disableMessage);
                    var dependencies        = projectDependencies.ShowDependencies(PackageConfigurator.DisableProject);
                    disableDependencies.AddRange(dependencies.Select(project => project.AssemblyName));
                }

                MessageBox.Show(string.Format("LINQBridge on {0} has been Disabled...", string.Join(", ", disableDependencies)), "Success", MessageBoxButtons.OK);

                break;

            default:
                throw new ArgumentOutOfRangeException("action");
            }
        }
Ejemplo n.º 2
0
        private int GetMultiStatus()
        {
            var result = 0;

            if (SelectedProject == null)
            {
                return(result);
            }

            if (PackageConfigurator.IsBridgeDisabled(SelectedAssemblyName, SolutionName))
            {
                result |= 1;
            }

            if (PackageConfigurator.IsBridgeEnabled(SelectedAssemblyName, SolutionName))
            {
                result |= 2;
            }

            return(result);
        }