예제 #1
0
        /// <summary>
        ///     把所有的要检测的文件夹放到虚拟目录
        /// </summary>
        /// <param name="folder"></param>
        /// <param name="progress"></param>
        /// <returns></returns>
        private List <EncodingScrutatorFolder> FolderToVirtualDirectory(List <string> folder,
                                                                        EncodingScrutatorProgress progress)
        {
            var encodingScrutatorFolder = new List <EncodingScrutatorFolder>();

            foreach (var temp in folder)
            {
                encodingScrutatorFolder.Add(
                    new EncodingScrutatorFolder(new DirectoryInfo(temp),
                                                _whiteList, _includeFile)
                {
                    Progress = progress,
                    SitpulationEncodingSetting = new SitpulationEncodingSetting
                    {
                        SitpulationEncoding = SitpulationEncoding
                    }
                });
            }


            _encodingScrutatorFolder = new EncodingScrutatorFolder(new DirectoryInfo(Environment.SystemDirectory))
            {
                Folder = encodingScrutatorFolder
            };

            foreach (var temp in encodingScrutatorFolder)
            {
                temp.Parent = _encodingScrutatorFolder;
            }

            return(encodingScrutatorFolder);
        }
예제 #2
0
        //规范编码之前,确保你已经管理所有代码

        /// <summary>
        ///     规范编码
        /// </summary>
        public void WriteCriterionEncoding()
        {
            var progress = new EncodingScrutatorProgress();
            var count    = 0;

            progress.WriteSitpulationFileChanged += (s, e) =>
            {
                var str = new StringBuilder();
                str.Append(e.GetEncodingScrutatorFileDirectory());
                str.Insert(0, "正在转换编码\r\n");
                Circular = str.ToString();
            };

            progress.ExceptChanged += (s, e) =>
            {
                count++;
                Circular += "\r\n转换出现异常" + e.Message;
            };

            new Task(() =>
            {
                WriteFolderEncoding.WriteSitpulationEncoding(EncodingScrutatorFolder, progress, SitpulationEncoding);
                Circular = "转换完成\r\n ";
                if (count > 0)
                {
                    Circular += "转换失败" + count;
                }
                else
                {
                    MessageBox.Show("转换完成", "编码规范工具");
                    PrintConformDispatcherSynchronizationContext(() => { Closing?.Invoke(this, null); });
                }
                FailWriteSitpulation();
            }).Start();
        }
예제 #3
0
        /// <summary>
        ///     检查多个文件夹文件编码
        /// </summary>
        /// <param name="folder"></param>
        public void InspectFolderEncoding(List <string> folder)
        {
            var progress = new EncodingScrutatorProgress();

            progress.ProgressChanged += Progress_ProgressChanged;

            ParseAccount();
            List <EncodingScrutatorFolder> encodingScrutatorFolder = FolderToVirtualDirectory(folder, progress);

            //};

            new Task(() =>
            {
                foreach (var temp in encodingScrutatorFolder)
                {
                    temp.InspectFolderEncoding();
                }
                //通知完成
                progress.Report(null);
            }).Start();
        }