public static string getFunctionCode(string methodname, string S, out string before, out string after, int ENTER_COUNT) { int N = 0; int start = 0; while ((N < ENTER_COUNT) && (start < S.Length)) { start = S.IndexOf("{", start) + 1; N++; } before = ""; after = ""; int limit = S.IndexOf("{", start); while ((limit >= 0) && (IsInsideComment(S, start, limit))) { limit = S.IndexOf("{", limit + 1); } if (limit < 0) { limit = S.Length; } string pattern = " " + methodname; string SS = S.Substring(start); int next = S.IndexOf(pattern, start, limit - start); while ((next >= 0) && (IsInsideComment(S, start, next)) && (next < limit)) { next = S.IndexOf(pattern, next + 1, limit - next - 1); } SS = S.Substring(start, limit - start); while ((next < 0) && (limit < S.Length)) { SS = S.Substring(limit); start = SkipComments.closeBlock(S, limit + 1, '{', '}'); if (start < 0) { string sss = methodname; } limit = S.IndexOf("{", start); while ((limit >= 0) && (IsInsideComment(S, start, limit))) { limit = S.IndexOf("{", limit + 1); } if (limit < 0) { limit = S.Length; } next = S.IndexOf(pattern, start, limit - start); while ((next >= 0) && (IsInsideComment(S, start, next)) && (next < limit)) { next = S.IndexOf(pattern, next + 1, limit - next - 1); } } if (next < 0) { before = S; after = ""; return(""); } int NNNNNNN = S.Length; int startblock = S.LastIndexOf('\n', next, next); int idx = S.IndexOf('{', startblock); int stop = SkipComments.closeBlock(S, idx + 1, '{', '}'); if (stop < 0) { stop = S.Length; } before = S.Substring(0, startblock); after = S.Substring(stop); return(S.Substring(startblock, stop - startblock)); }