public static Builder <P, PP, PPP> Line <T, P, PP, PPP>(this Builder <P, PP, PPP> b, string format, Func <P, T> selector, params object[] objs) where PPP : class { var lb = new LineBuilder <T, P, Builder <P, PP, PPP> >(b, selector); var currentIndent = indent; lb.AddConcat((sb, v) => { var space = new string(' ', currentIndent * tabSize); var currentFormat = format; currentFormat = currentFormat.Replace("{0}", v.ToString()); for (int i = 0; i < objs.Length; i++) { currentFormat = currentFormat.Replace(string.Format("{{{0}}}", i + 1), string.Format("{{{0}}}", i)); } if (objs.Length > 0) { sb.Append(space).AppendFormat(currentFormat, objs).AppendLine(); } else { sb.Append(space).Append(currentFormat).AppendLine(); } }); return(lb.End()); }
public static Builder <P, PP, PPP> Line <P, PP, PPP>(this Builder <P, PP, PPP> b) where PPP : class { var lb = new LineBuilder <int, P, Builder <P, PP, PPP> >(b, null); lb.AddConcat((sb, v) => { sb.AppendLine(); }); return(lb.End()); }
public static Builder <P, PP, PPP> Line <P, PP, PPP>(this Builder <P, PP, PPP> b, string format, params object[] objs) where PPP : class { var lb = new LineBuilder <int, P, Builder <P, PP, PPP> >(b, null); var currentIndent = indent; var c = new Action <StringBuilder, int>((sb, p) => { var space = new string(' ', currentIndent * tabSize); var currentFormat = format; if (objs.Length > 0) { sb.Append(space).AppendFormat(currentFormat, objs).AppendLine(); } else { sb.Append(space).Append(currentFormat).AppendLine(); } }); lb.AddConcat(c); return(lb.End()); }