Example #1
0
        public void Analyze(bool replace)
        {
            if (!FileOperator.CheckExitsFile(_baseFile))
            {
                return;
            }

            if (!FileOperator.CheckNotZeroLength(_baseFile))
            {
                return;
            }

            string tempFullPath = null;

            if (replace)   //If search substring and replace it with the pattern
            {
                bool tempFileCreated = FileOperator.TempFileCreateOrDelete(_baseFile, TEMP_FILE_NAME, out tempFullPath);

                if (!string.IsNullOrEmpty(tempFullPath))
                {
                    ParserText.ReplacePatternInFile(_baseFile, tempFullPath, _searchString, _pattern, tempFileCreated);
                    FileOperator.ReplaceFiles(_baseFile, tempFullPath);
                }
            }
            else         //Count sunbstrings inclusions amount
            {
                bool resultFileCreated = FileOperator.TempFileCreateOrDelete(_baseFile, RESULT_FILE_NAME, out tempFullPath);

                if (!string.IsNullOrEmpty(tempFullPath))
                {
                    ParserText.CountContainedInFile(_baseFile, RESULT_FILE_NAME, _searchString, resultFileCreated);
                }
            }
        }
Example #2
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="pt"></param>
 protected void Init(ParserText pt)
 {
     FilePath      = pt.Path;
     this.RootPath = pt.RootPath;
     if (pt.Content.IsNull())
     {
         CodeStrings = Tools.ReadFileLins(pt.Path);
     }
     else
     {
         CodeStrings = pt.Content;
     }
 }
 /// <summary>
 /// 执行 开始分析代码
 /// </summary>
 /// <param name="pt"></param>
 /// <returns></returns>
 public override BEleme Execute(ParserText pt)
 {
     this.Init(pt);
     this.Line();
     return(this.LumpElem);
 }
Example #4
0
 /// <summary>
 /// 执行
 /// </summary>
 public abstract BEleme Execute(ParserText pt);