MCPcopy Create free account
hub / github.com/apache/thrift / ToString

Method ToString

lib/netstd/Thrift/Protocol/ToString.cs:31–83  ·  view source on GitHub ↗
(this object self, StringBuilder sb, bool first = true)

Source from the content-addressed store, hash-verified

29 public static class ToStringExtensions
30 {
31 public static void ToString(this object self, StringBuilder sb, bool first = true)
32 {
33 if (!first)
34 sb.Append(", ");
35
36 bool first_child = true;
37 if (self is string str) // string is IEnumerable
38 {
39 sb.Append('"');
40 sb.Append(str);
41 sb.Append('"');
42 }
43 else if (self is IDictionary dict)
44 {
45 sb.Append("{ ");
46 foreach (DictionaryEntry pair in dict)
47 {
48 if (first_child)
49 first_child = false;
50 else
51 sb.Append(',');
52
53 sb.Append("{ ");
54 pair.Key.ToString(sb);
55 sb.Append(", ");
56 pair.Value.ToString(sb);
57 sb.Append('}');
58 }
59 sb.Append('}');
60 }
61 else if (self is IEnumerable enumerable)
62 {
63 sb.Append("{ ");
64 foreach (var elm in enumerable)
65 {
66 elm.ToString(sb, first_child);
67 first_child = false;
68 }
69 sb.Append('}');
70 }
71 else if (self is TBase tbase)
72 {
73 sb.Append(tbase.ToString());
74 }
75 else if (self is double dbVal)
76 {
77 sb.Append(dbVal.ToString(CultureInfo.InvariantCulture));
78 }
79 else
80 {
81 sb.Append(self != null ? self.ToString() : "<null>");
82 }
83 }
84 }
85
86

Callers 15

calculateMethod · 0.80
ServeAsyncMethod · 0.80
ServeAsyncMethod · 0.80
THttpTransportMethod · 0.80
ReadAsyncMethod · 0.80
FlushAsyncMethod · 0.80
SetupTlsAsyncMethod · 0.80
WriteJsonIntegerAsyncMethod · 0.80
WriteJsonDoubleAsyncMethod · 0.80

Calls

no outgoing calls

Tested by 7

TestConsoleLoggerMethod · 0.64
testUuidMethod · 0.64
testMapMethod · 0.64
testStringMapMethod · 0.64
testSetMethod · 0.64
testListMethod · 0.64