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

◆ ParseSortString()

IndexField[] System.Data.DataTable.ParseSortString ( string sortString)
inlinepackageinherited

Definition at line 3339 of file DataTable.cs.

3340 {
3341 IndexField[] array = Array.Empty<IndexField>();
3342 if (sortString != null && 0 < sortString.Length)
3343 {
3344 string[] array2 = sortString.Split(',', StringSplitOptions.TrimEntries);
3345 array = new IndexField[array2.Length];
3346 for (int i = 0; i < array2.Length; i++)
3347 {
3348 string text = array2[i];
3349 int length = text.Length;
3350 bool isDescending = false;
3351 if (length >= 5 && string.Compare(text, length - 4, " ASC", 0, 4, StringComparison.OrdinalIgnoreCase) == 0)
3352 {
3353 text = text.AsSpan(0, length - 4).Trim().ToString();
3354 }
3355 else if (length >= 6 && string.Compare(text, length - 5, " DESC", 0, 5, StringComparison.OrdinalIgnoreCase) == 0)
3356 {
3357 isDescending = true;
3358 text = text.AsSpan(0, length - 5).Trim().ToString();
3359 }
3360 if (text.StartsWith('['))
3361 {
3362 if (!text.EndsWith(']'))
3363 {
3364 throw ExceptionBuilder.InvalidSortString(array2[i]);
3365 }
3366 text = text.Substring(1, text.Length - 2);
3367 }
3368 DataColumn dataColumn = Columns[text];
3369 if (dataColumn == null)
3370 {
3371 throw ExceptionBuilder.ColumnOutOfRange(text);
3372 }
3373 array[i] = new IndexField(dataColumn, isDescending);
3374 }
3375 }
3376 return array;
3377 }
int Compare(string s1, string s2)
DataColumnCollection Columns
Definition DataTable.cs:327

References System.array, System.Data.ExceptionBuilder.ColumnOutOfRange(), System.Data.DataTable.Columns, System.Data.DataTable.Compare(), System.Data.ExceptionBuilder.InvalidSortString(), System.length, and System.text.

Referenced by System.Data.Select.Select(), System.Data.DataView.CheckSort(), and System.Data.DataTable.GetIndex().