예제 #1
0
        private void Excute(object sender, EventArgs e)
        {
            _myOutPane.Activate();
            _lstExcludePath = _dte.GetExcludePathList();
            _count          = 0;

            _selectedMenu = (PkgCmdIdList)((MenuCommand)sender).CommandID.ID;

            var table = new RunningDocumentTable(this);

            _lstAlreadyOpenFiles = table.Select(p => p.Moniker).ToList();

            var selectedItem = _dte.SelectedItems.Item(1);

            WriteLog($"{Environment.NewLine}====================================================================================");
            WriteLog($"Start: {DateTime.Now}");


            var sp = new Stopwatch();

            sp.Start();

            //以下判断只会进一次
            if (selectedItem.Project == null && selectedItem.ProjectItem == null) //从解决方案一级进来的
            {
                ProcessSolution();
            }
            else if (selectedItem.Project != null) //从项目一级进来的
            {
                ProcessProject(selectedItem.Project);
            }
            else if (selectedItem.ProjectItem != null)               //从文件夹一级或者文件一级进来的
            {
                if (selectedItem.ProjectItem.ProjectItems.Count > 0) //此项下页还有文件,如:文件夹,T4模板
                {
                    ProcessProjectItem(selectedItem.ProjectItem);
                    ProcessProjectItems(selectedItem.ProjectItem.ProjectItems);
                }
                else //此项下什么都没有了,直接处理
                {
                    ProcessProjectItem(selectedItem.ProjectItem);
                }
            }
            sp.Stop();

            WriteLog($"Finish: {DateTime.Now}  Files: {_count - 2}  Elapsed: {sp.ElapsedMilliseconds / 1000}s");
            _dte.ExecuteCommand("View.Output");
            _myOutPane.Activate();
        }