/// Function - SearchPattern /// <summary> /// /// </summary> /// <param name="Pattern"> The pattern that it search type Regex.</param> /// <param name="returnSize"> size of the return code.</param> /// <param name="filePath"> the path of the file type string.</param> /// <returns> An array of strings that contains all of the code that matches the patterns.</returns> public static string [] SearchPattern(Regex Pattern, string returnSize, string filePath) { ArrayList results = new ArrayList(); MyStream sr = new MyStream(filePath, System.Text.Encoding.UTF8); uint pos = sr.Pos; Stack s = new Stack(); string blockLine = ""; bool modelStopWhile = false; string codeLine; while ((codeLine = sr.ReadLine()) != null && !modelStopWhile) { if (codeLine.IndexOf("{") != GeneralConsts.NOT_FOUND_STRING) { pos = sr.Pos; blockLine = codeLine; s.Push(codeLine); } if (codeLine.IndexOf("}") != GeneralConsts.NOT_FOUND_STRING) { s.Pop(); } if (Pattern.IsMatch(codeLine)) { if (returnSize == "model") { modelStopWhile = true; sr.Seek(0); results.Add(sr.ReadToEnd()); } else if (returnSize == "scope") { if (s.Count == 0) { pos = 0; } if (!results.Contains(ReadAllScope(sr, pos, blockLine))) { results.Add(ReadAllScope(sr, pos, blockLine)); } } else if (returnSize == "line") { results.Add(codeLine); } } } string[] finalResult = (string[])results.ToArray(typeof(string)); return(finalResult); }