private Task UpdateFrameworks(FrameworkModel frameworkModel)
        {
            return(Task.Run(() =>
            {
                var enumerable = projectsUpdateList.Projects.Where(p => p.IsSelected);

                foreach (var projectModel in enumerable)
                {
                    try
                    {
                        projectModel.DteProject.Properties.Item("TargetFrameworkMoniker").Value = frameworkModel.Moniker;

                        synchronizationContext.Post(o =>
                        {
                            var pm = (ProjectModel)o;
                            projectsUpdateList.State = string.Format("Updating... {0} done", pm.Name);
                        }, projectModel);
                    }
                    catch (COMException e) //possible "project unavailable" for unknown reasons
                    {
                        Debug.WriteLine("COMException on " + projectModel.Name + e);
                    }
                }
            }));
        }
        async void Update()
        {
            FrameworkModel frameworkModel = projectsUpdateList.SelectedFramework;

            projectsUpdateList.State = "Updating...";

            await UpdateFrameworks(frameworkModel);

            projectsUpdateList.Projects = LoadProjects();

            projectsUpdateList.State = "Done";
        }
        async void Update(Action <int, object> progresReport)
        {
            //FrameworkModel frameworkModel = projectsUpdateList.SelectedFramework;
            FrameworkModel frameworkModel = null;

            progresReport(0, "Updating...");

            await UpdateFrameworks(frameworkModel, progresReport);

            projectsUpdateList.Projects = LoadProjects();

            progresReport(100, "Done");
        }
Beispiel #4
0
        private static ProjectModel MapProject(Project p)
        {
            var projectModel = new ProjectModel
            {
                Name       = p.Name,
                DteProject = p,
            };

            if (p.Properties == null)
            {
                return(projectModel);
            }


            try
            {
                // check if not applicable for current project
                if (p.Properties.Item("TargetFramework") == null ||
                    p.Properties.Item("TargetFrameworkMoniker") == null)
                {
                    return(projectModel);
                }
            }
            catch (ArgumentException e)
            {
                Debug.WriteLine("ArgumentException on " + projectModel + e);
                return(projectModel);
            }

            try
            {
                var frameworkModel = new FrameworkModel
                {
                    Id   = (uint)p.Properties.Item("TargetFramework").Value,
                    Name = (string)p.Properties.Item("TargetFrameworkMoniker").Value
                };
                projectModel.Framework = frameworkModel;
            }
            catch (ArgumentException e) //possible when project still loading
            {
                Debug.WriteLine("ArgumentException on " + projectModel + e);
            }
            catch (InvalidCastException e) //for some projects with wrong types
            {
                Debug.WriteLine("InvalidCastException on " + projectModel + e);
            }
            return(projectModel);
        }