/// <inheritdoc /> public string?Format(object?value, Type valueType) { if (value is ValueTuple <string, object?> nameValueTuple) { return($"({nameValueTuple.Item1}: {_valueFormatter.TryFormat(nameValueTuple.Item2)})"); } return(null); }
/// <inheritdoc /> public string?Format(object?value, Type valueType) { if (value is KeyValuePair <string, object?> keyValuePair) { return($"({keyValuePair.Key}: {_valueFormatter.TryFormat(keyValuePair.Value)})"); } return(null); }
public void RecursiveFormatting() { List <KeyValuePair <string, object> > list = new List <KeyValuePair <string, object> >(); list.Add(new KeyValuePair <string, object>("Key1", new LocalDate(2021, 01, 23))); list.Add(new KeyValuePair <string, object>("Key2", new [] { "a1", "a2" })); list.Add(new KeyValuePair <string, object>("Key3", ("Internal", 5))); IValueFormatter fullToStringFormatter = Formatter.FullRecursiveFormatter; string? formattedValue = fullToStringFormatter.TryFormat(list); formattedValue.Should().Be("[(Key1: 2021-01-23), (Key2: [a1, a2]), (Key3: (Internal, 5))]"); }