Ejemplo n.º 1
0
 public MultiReference(string source, MultiReferenceType type)
 {
     if (type == MultiReferenceType.Assembly)
     {
         AssemblySource = source;
     }
     else
     {
         ProjectSource  = source;
         AssemblySource = SolutionParser.GetAssemblyNameFromProject(ProjectSource);
     }
     this.Type = type;
 }
Ejemplo n.º 2
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();
     }
 }
Ejemplo n.º 3
0
        static IEnumerable <MultiReference> ChangeVersion(IDteWrapper dte, ProjectType projectType, string newVersion)
        {
            var assemblyReferences = dte.GetReferences(x => x.Name.Contains("DevExpress")).Select(x => new MultiReference(x.Name, MultiReferenceType.Assembly).Do(mr => mr.ReplaceVersion(newVersion)));
            var projectReferences  = dte.GetProjects(x => x.Name.Contains("DevExpress")).Select(x => new MultiReference(x.FullName, MultiReferenceType.Project).Do(mr => mr.ReplaceVersion(newVersion)));

            var assemplyReferenceNames = assemblyReferences.Select(x => x.AssemblySource);
            var projectReferenceNames  = projectReferences.Select(x => x.AssemblySource);

            var model = SerializeHelper.DeSerializeNavigationConfig();

            var projects       = model.NavigateItems.Where(x => x.GeneratedProjects != null).SelectMany(x => x.GeneratedProjects).Distinct();
            var targetProjects = projects.Select(x => new MultiReference(x, MultiReferenceType.Project)).Where(project => {
                var projectRoot = ProjectRootElement.Open(project.ProjectSource);
                if (project.ProjectSource.Contains("Localization") || SolutionParser.GetProjectType(projectRoot).Conflicts(projectType))
                {
                    return(false);
                }
                var assemblyNameProperty = SolutionParser.GetAssemblyNameFromProject(projectRoot).If(DXControlsVersionHelper.HasDXVersionInfo);
                if (assemblyNameProperty == null)
                {
                    return(false);
                }
                if (projectReferenceNames.Contains(assemblyNameProperty))
                {
                    project.Type = MultiReferenceType.Project;
                    return(true);
                }
                if (assemplyReferenceNames.Contains(assemblyNameProperty))
                {
                    project.Type = MultiReferenceType.Assembly;
                    return(true);
                }
                return(false);
            }).ToList();
            var dependentProjects = targetProjects.SelectMany(x => SolutionParser.GetDXReferencePaths(x.ProjectSource, true)).Where(x => !ReferenceInfo.IsEmpty(x)).Select(x => new MultiReference(x)).ToList();

            return(Concat(targetProjects.ToList(), dependentProjects.ToList()).Distinct());
        }
Ejemplo n.º 4
0
        public ProjectType GetProjectType(string path)
        {
            SolutionParser parser = new SolutionParser(path);

            return(parser.GetProjectType());
        }
Ejemplo n.º 5
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");
            }
        }