public void EndLoop(int id) { string[] names = this.values.Keys.ToArray(); if (names.Length == 0) { this.loopLevel--; return; } StringBuilder fBuilder = new StringBuilder(); fBuilder.Append("| "); for (int i = 0; i < names.Length; ++i) { int size = names[i].Length; if (size < 5) { size = 5; } fBuilder.Append("{" + i + ",-" + size + "} | "); } string format = fBuilder.ToString(); this.builder.AppendLine(String.Format(format, this.values.Keys.Cast <object>().ToArray())); List <object>[] valueLists = new List <object> [names.Length]; for (int i = 0; i < names.Length; ++i) { valueLists[i] = this.values[names[i]]; } int lcount = valueLists.Max(l => l.Count); for (int i = 0; i < lcount; ++i) { if (i == MaximumLoops && i != 0) { this.builder.AppendLine(String.Format("{0:N0} loops not shown", lcount - MaximumLoops)); break; } object[] vs = new object[valueLists.Length]; for (int n = 0; n < valueLists.Length; ++n) { List <object> nvs = valueLists[n]; if (nvs.Count > i) { vs[n] = Display.Object(valueLists[n][i]); } } this.builder.AppendLine(String.Format(format, vs)); } this.values.Clear(); this.loopLevel--; }
public T LogReturn <T> (int id, T value) { while (this.loopLevel > 0) { EndLoop(id); } this.builder.Append("return "); this.builder.AppendLine(Display.Object(value)); return(value); }
public T LogObject <T> (int id, string name, T value) { if (this.loopLevel > 0) { List <object> vs; if (!this.values.TryGetValue(name, out vs)) { this.values [name] = vs = new List <object>(); vs.AddRange(Enumerable.Repeat(Skipped, this.iteration)); } vs.Add(value); } //else //{ AddOperation(new StateChange(id, name, Display.Object(value))); //} return(value); }
public T LogObject <T> (int id, string name, T value) { if (this.loopLevel > 0) { List <object> vs; if (!this.values.TryGetValue(name, out vs)) { this.values [name] = vs = new List <object>(); vs.AddRange(Enumerable.Repeat(Skipped, this.iteration)); } vs.Add(value); } else { this.builder.Append(name); this.builder.Append(" = "); this.builder.AppendLine(Display.Object(value)); } return(value); }