Esempio n. 1
0
 public void AddReferences(IDteWrapper dte, NavigateItem item)
 {
     try {
         BusyIndicator.Show();
         dte.ClearReferences();
         SolutionParser parser = new SolutionParser(item.Path);
         foreach (var assembly in parser.GetReferencedAssemblies(true))
         {
             dte.AddReference(assembly);
         }
     }
     finally {
         BusyIndicator.Close();
     }
 }
Esempio n. 2
0
        public void AddReferencesImpl(IDteWrapper dte, NavigateItem item, bool addAsProjectReference)
        {
            dte.LockCurrentProject();
            try {
                BusyIndicator.Show();

                string         path        = item.Path;
                SolutionParser parser      = new SolutionParser(path);
                var            projectType = parser.GetProjectType();

                var newAssemblies = parser.GetReferencedAssemblies(!addAsProjectReference).Select(x => new MultiReference(x));
                var newVersion    = newAssemblies.Select(x => x.AssemblySource).FirstOrDefault(DXControlsVersionHelper.HasDXVersionInfo).With(DXControlsVersionHelper.GetDXVersionString);

                BusyIndicator.UpdateText("Search for references...");

                var cache = SerializeHelper.DeserializeAddReferenceHelperCache();
                var updatedReferenceCachedItem = cache.GetItem(path);
                IEnumerable <MultiReference> updatedReferences = null;
                if (updatedReferenceCachedItem != null)
                {
                    updatedReferences = updatedReferenceCachedItem.References.Select(x => new MultiReference(x)).ToList();
                }
                else
                {
                    updatedReferences = ChangeVersion(dte, projectType, newVersion).ToList();
                    cache.AddItem(new AddReferenceHelperItem()
                    {
                        Solution = path, References = updatedReferences.Where(x => x.ReferenceSource != null).Select(x => x.ReferenceSource).ToList()
                    });
                    SerializeHelper.SerializeAddReferenceHelperCache(cache);
                }

                BusyIndicator.UpdateText("Preparing project...");

                dte.ClearReferences();
                dte.ClearProjectReferences();

                var actualReferences = Concat(newAssemblies, updatedReferences);
                if (addAsProjectReference)
                {
                    actualReferences = Concat(actualReferences, parser.GetProjectPathes().Select(x => new MultiReference(x, MultiReferenceType.Project)));
                }
                foreach (var reference in actualReferences)
                {
                    try {
                        if (reference.Type == MultiReferenceType.Assembly)
                        {
                            var assembly = projectType == ProjectType.SL ? reference.FullAssemblySource : reference.AssemblySource;
                            BusyIndicator.UpdateText("Add reference: " + assembly);
                            dte.AddReference(assembly);
                        }
                        else
                        {
                            var project = reference.ProjectSource;
                            BusyIndicator.UpdateText("Add project: " + project);
                            dte.AddProjectReference(reference.ProjectSource);
                        }
                    } catch { }
                }
            }
            finally {
                BusyIndicator.Close();
                dte.UnlockCurrentProject();
                dte.ActivateConfiguration("DebugTest");
            }
        }