Пример #1
0
        public string GetStack(int firstOffset = 0)
        {
            StringBuilder result = new StringBuilder();
            ParsingScript script = this;

            while (script != null)
            {
                int    pointer    = script == this ? script.Pointer + firstOffset : script.Pointer;
                int    lineNumber = script.GetOriginalLineNumber(pointer);
                string filename   = string.IsNullOrWhiteSpace(script.Filename) ? "" :
                                    Utils.GetFullPath(script.Filename);
                string line = string.IsNullOrWhiteSpace(filename) || !File.Exists(filename) ? "" :
                              File.ReadLines(filename).Skip(lineNumber).Take(1).First();

                result.AppendLine("" + lineNumber);
                result.AppendLine(filename);
                result.AppendLine(line.Trim());

                script = script.ParentScript;
            }

            return(result.ToString().Trim());
        }