Exemplo n.º 1
0
        internal void Execute(object state)
        {
            AssemblyComparerThread act = (AssemblyComparerThread)state;

            try
            {
                if (act.Progress != null)
                {
                    if (act.Progress.CancelRequested)
                    {
                        throw new OperationCanceledException();
                    }

                    act.Progress.UpdateProgress(new ProgressStatus("Analyzing " + act.FileName, true));
                }

                AssemblyDetail assembly = act.Manager.ExtractAssemblyInf(act.FileName, _config);
                assembly.Name = act.Group.Name;

                lock (GetType())
                {
                    act.Group.Assemblies.Add(assembly);
                }
            }
            catch (Exception ex)
            {
                Log.Error("Unable to load assembly : {0}", act.FileName);
                act.Group.HasErrors   = true;
                act.Group.ErrorDetail = ex.GetNestedExceptionMessage();
                Log.Error(act.Group.ErrorDetail);
            }
        }
Exemplo n.º 2
0
        private AssemblyGroup DoCompareFiles(AssemblyManager manager, string[] assemblyFiles)
        {
            string[] assemblyFilesResolved = new string[assemblyFiles.Length];

            for (int i = 0; i < assemblyFiles.Length; i++)
            {
                if (Path.IsPathRooted(assemblyFiles[i]))
                {
                    assemblyFilesResolved[i] = Path.GetFullPath(assemblyFiles[i]);
                }
                else
                {
                    assemblyFilesResolved[i] = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), assemblyFiles[i]));
                }
            }

            AssemblyGroup group = new AssemblyGroup();

            foreach (string file in assemblyFilesResolved)
            {
                if (group.Name == null)
                {
                    group.Name = Path.GetFileName(file);
                }

                if (Path.GetFileName(file) != group.Name)
                {
                    group.Name = "(Multiple Names)";
                    break;
                }
            }

            foreach (string fileName in assemblyFilesResolved)
            {
                AssemblyComparerThread act = new AssemblyComparerThread(manager, group, fileName, _progress);

                if (_config.Multithread)
                {
                    _tpw.QueueUserWorkItem(Execute, act);
                }
                else
                {
                    Execute(act);
                }
            }

            if (_config.Multithread)
            {
                _tpw.WaitOne();

                List <AssemblyDetail> sorted = new List <AssemblyDetail>();

                foreach (string fileName in assemblyFilesResolved)
                {
                    AssemblyDetail sortedDetail = group.Assemblies.Find(delegate(AssemblyDetail detail) { return(string.Compare(detail.Location, fileName, true) == 0); });

                    if (sortedDetail == null)
                    {
                        Log.Error("Unable to sort assembly " + fileName);
                        //Log.Error(" List has " + string.Join(",", group.Assemblies.ConvertAll(delegate(AssemblyDetail detail) { return detail.Location; }).ToArray()));
                    }
                    else
                    {
                        sorted.Add(sortedDetail);
                    }
                }

                group.Assemblies.Clear();
                group.Assemblies.AddRange(sorted);
            }

            ListOperations.AlignLists(group.Assemblies);

            group.PerformCompare(_filter);

            return(group);
        }
Exemplo n.º 3
0
        private AssemblyGroup DoCompareFiles(AssemblyManager manager, string[] assemblyFiles)
        {
            string[] assemblyFilesResolved = new string[assemblyFiles.Length];

            for (int i = 0; i < assemblyFiles.Length; i++)
            {
                if (Path.IsPathRooted(assemblyFiles[i]))
                {
                    assemblyFilesResolved[i] = assemblyFiles[i];
                }
                else
                {
                    assemblyFilesResolved[i] = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), assemblyFiles[i]));
                }
            }

            AssemblyGroup group = new AssemblyGroup();

            foreach (string file in assemblyFilesResolved)
            {
                if (group.Name == null)
                {
                    group.Name = Path.GetFileName(file);
                }

                if (Path.GetFileName(file) != group.Name)
                {
                    group.Name = "(Multiple Names)";
                    break;
                }
            }

            foreach (string fileName in assemblyFilesResolved)
            {
                AssemblyComparerThread act = new AssemblyComparerThread(manager, group, fileName, _progress);

                if (_config.Multithread)
                {
                    _tpw.QueueUserWorkItem(Execute, act);
                }
                else
                {
                    Execute(act);
                }
            }

            if (_config.Multithread)
            {
                _tpw.WaitOne();

                List<AssemblyDetail> sorted = new List<AssemblyDetail>();

                foreach (string fileName in assemblyFilesResolved)
                {
                    AssemblyDetail sortedDetail = group.Assemblies.Find(delegate(AssemblyDetail detail) { return string.Compare(detail.Location, fileName, true) == 0; });

                    if (sortedDetail == null)
                    {
                        Log.Error("Unable to sort assembly " + fileName);
                        //Log.Error(" List has " + string.Join(",", group.Assemblies.ConvertAll(delegate(AssemblyDetail detail) { return detail.Location; }).ToArray()));
                    }
                    else
                    {
                        sorted.Add(sortedDetail);
                    }
                }

                group.Assemblies.Clear();
                group.Assemblies.AddRange(sorted);
            }

            ListOperations.AlignLists(group.Assemblies);

            group.PerformCompare(_filter);

            return group;
        }