public static bool TryParse(string format, out ValuesFormatter formatter) { if (string.IsNullOrEmpty(format)) { formatter = Empty; return(true); } //if ( format.IndexOf( '{' ) < 0 ) { // formatter = new ValuesFormatter( format ); // return true; //} Parser parser = default; if (parser.TryParse(format)) { if (parser.Count == 1) { var seg = parser.Segments[0]; if (seg.Type == SegmentType.Text && seg.Format == format) { formatter = new ValuesFormatter(format); return(true); } } formatter = new ValuesFormatter(format, parser.Segments, parser.Names); return(true); } formatter = null; return(false); }
public static ValuesLog Get(string message, object[] args) { if (args != null) { int length = args.Length; if (length > 0) { ValuesFormatter f = ValuesFormatter.Get(message); if (f.Count > length) { throw new ArgumentException(message, nameof(args)); } return(new ValuesLog(f, args)); } } return(null); }
private ValuesLog(ValuesFormatter formatter, IReadOnlyList <object> values) { _formatter = formatter; _values = values; }