Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ JsonPath()

string System.Text.Json.ReadStack.JsonPath ( )
inline

Definition at line 143 of file ReadStack.cs.

144 {
145 StringBuilder stringBuilder = new StringBuilder("$");
146 int num = Math.Max(_count, _continuationCount);
147 for (int i = 0; i < num - 1; i++)
148 {
150 }
151 if (_continuationCount == 0)
152 {
154 }
155 return stringBuilder.ToString();
156 static void AppendPropertyName(StringBuilder sb, string propertyName)
157 {
158 if (propertyName != null)
159 {
160 if (propertyName.IndexOfAny(SpecialCharacters) != -1)
161 {
162 sb.Append("['");
163 sb.Append(propertyName);
164 sb.Append("']");
165 }
166 else
167 {
168 sb.Append('.');
169 sb.Append(propertyName);
170 }
171 }
172 }
173 static void AppendStackFrame(StringBuilder sb, ref ReadStackFrame frame)
174 {
175 string propertyName2 = GetPropertyName(ref frame);
177 if (frame.JsonTypeInfo != null && frame.IsProcessingEnumerable() && frame.ReturnValue is IEnumerable enumerable2 && (frame.ObjectState == StackFrameObjectState.None || frame.ObjectState == StackFrameObjectState.CreatedObject || frame.ObjectState == StackFrameObjectState.ReadElements))
178 {
179 sb.Append('[');
180 sb.Append(GetCount(enumerable2));
181 sb.Append(']');
182 }
183 }
184 static int GetCount(IEnumerable enumerable)
185 {
186 if (enumerable is ICollection collection)
187 {
188 return collection.Count;
189 }
190 int num2 = 0;
191 IEnumerator enumerator = enumerable.GetEnumerator();
192 while (enumerator.MoveNext())
193 {
194 num2++;
195 }
196 return num2;
197 }
198 static string GetPropertyName(ref ReadStackFrame frame)
199 {
200 string result = null;
201 byte[] array = frame.JsonPropertyName;
202 if (array == null)
203 {
204 if (frame.JsonPropertyNameAsString != null)
205 {
206 result = frame.JsonPropertyNameAsString;
207 }
208 else
209 {
210 array = frame.JsonPropertyInfo?.NameAsUtf8Bytes ?? frame.CtorArgumentState?.JsonParameterInfo?.NameAsUtf8Bytes;
211 }
212 }
213 if (array != null)
214 {
215 result = JsonHelpers.Utf8GetString(array);
216 }
217 return result;
218 }
219 }
static readonly char[] SpecialCharacters
Definition ReadStack.cs:13
ReadStackFrame Current
Definition ReadStack.cs:19
ReadStackFrame[] _stack
Definition ReadStack.cs:21

References System.Text.Json.ReadStack._continuationCount, System.Text.Json.ReadStack._count, System.Text.Json.ReadStack._stack, System.Text.StringBuilder.Append(), System.array, System.collection, System.Text.Json.ReadStack.Current, System.Text.Json.Dictionary, System.Math.Max(), System.Text.Json.ReadStack.SpecialCharacters, and System.Text.Json.JsonHelpers.Utf8GetString().