• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MorganKryze / ConsoleAppVisuals / 7972444880

pending completion
7972444880

push

github

MorganKryze
📖 add legacy docs

827 of 916 branches covered (90.28%)

Branch coverage included in aggregate %.

1676 of 1694 relevant lines covered (98.94%)

105.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.63
/src/ConsoleAppVisuals/elements/TableView.cs
1
/*
2
    GNU GPL License 2024 MorganKryze(Yann Vidamment)
3
    For full license information, please visit: https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/LICENSE
4
*/
5
namespace ConsoleAppVisuals;
6

7
/// <summary>
8
/// The <see cref="TableView{T}"/> class that contains the methods to create a table and display it.
9
/// </summary>
10
public class TableView<T> : Element
11
{
12
    #region Fields: title, headers, lines, display array, rounded corners
13
    private string? _title;
14
    private List<string>? _rawHeaders;
15
    private List<List<T>>? _rawLines;
16
    private string[]? _displayArray;
17
    private bool _roundedCorners;
18
    private readonly int _line;
19
    private readonly Placement _placement;
20
    #endregion
21

22
    #region Properties: get headers, get lines
23
    /// <summary>
24
    /// This property returns the headers of the table.
25
    /// </summary>
26
    public List<string>? GetRawHeaders => _rawHeaders;
18✔
27

28
    /// <summary>
29
    /// This property returns the lines of the table.
30
    /// </summary>
31
    public List<List<T>>? GetRawLines => _rawLines;
15✔
32

33
    /// <summary>
34
    /// This property returns the title of the table.
35
    /// </summary>
36
    public override Placement Placement => _placement;
102✔
37

38
    /// <summary>
39
    /// This property returns the line to display the table on.
40
    /// </summary>
41
    public override int Line => _line;
18✔
42

43
    /// <summary>
44
    /// This property returns the height of the table.
45
    /// </summary>
46
    public override int Height => _displayArray?.Length ?? 0;
63✔
47

48
    /// <summary>
49
    /// This property returns the width of the table.
50
    /// </summary>
51
    public override int Width => _displayArray?.Max(x => x.Length) ?? 0;
117✔
52

53
    /// <summary>
54
    /// This property returns the maximum number of this element that can be displayed on the console.
55
    /// </summary>
56
    public override int MaxNumberOfThisElement { get; } = 9;
309✔
57

58
    #endregion
59

60
    #region Constructor
61
    /// <summary>
62
    /// The <see cref="TableView{T}"/> natural constructor.
63
    /// </summary>
64
    /// <param name="title">The title of the table.</param>
65
    /// <param name="headers">The headers of the table.</param>
66
    /// <param name="lines">The lines of the table.</param>
67
    /// <param name="roundedCorners">The rounded corners of the table.</param>
68
    /// <param name="placement">The placement of the table.</param>
69
    /// <param name="line">The line to display the table on.</param>
70
    /// <exception cref="ArgumentException">Is thrown when the number of columns in the table is not consistent with itself or with the headers.</exception>
71
    /// <exception cref="NullReferenceException">Is thrown when no body lines were provided.</exception>
72
    /// <remarks>Refer to the example project to understand how to implement it available at https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs </remarks>
73
    public TableView(
219✔
74
        string? title = null,
219✔
75
        List<string>? headers = null,
219✔
76
        List<List<T>>? lines = null,
219✔
77
        bool roundedCorners = false,
219✔
78
        Placement placement = Placement.TopCenter,
219✔
79
        int? line = null
219✔
80
    )
219✔
81
    {
82
        _title = title;
219✔
83
        _rawHeaders = headers;
219✔
84
        _rawLines = lines;
219✔
85
        _roundedCorners = roundedCorners;
219✔
86
        _placement = placement;
219✔
87
        _line = Window.CheckLine(line) ?? Window.GetLineAvailable(placement);
219!
88
        if (CompatibilityCheck())
219✔
89
        {
90
            BuildTable();
186✔
91
        }
92
    }
213✔
93
    #endregion
94

95
    #region Check Methods
96
    private bool CompatibilityCheck()
97
    {
98
        if (_rawHeaders is null)
228✔
99
        {
100
            return CheckRawLines();
30✔
101
        }
102
        else if (_rawLines is null)
198✔
103
        {
104
            return true;
45✔
105
        }
106
        else
107
        {
108
            return CheckRawHeadersAndLines();
153✔
109
        }
110
    }
111

112
    private bool CheckRawLines()
113
    {
114
        if (_rawLines is null || _rawLines.Count == 0)
30✔
115
        {
116
            return false;
15✔
117
        }
118

119
        for (int i = 0; i < _rawLines.Count; i++)
84✔
120
        {
121
            if (_rawLines[i].Count != _rawLines[0].Count)
30✔
122
            {
123
                throw new ArgumentException(
3✔
124
                    "The number of columns in the table is not consistent."
3✔
125
                );
3✔
126
            }
127
        }
128
        return true;
12✔
129
    }
130

131
    private bool CheckRawHeadersAndLines()
132
    {
133
        if (_rawLines is null || _rawLines.Count == 0)
153✔
134
        {
135
            return false;
12✔
136
        }
137

138
        if (_rawLines.Count > 0)
141✔
139
        {
140
            for (int i = 0; i < _rawLines.Count; i++)
798✔
141
            {
142
                if (_rawLines[i].Count != _rawHeaders?.Count)
264!
143
                {
144
                    throw new ArgumentException(
6✔
145
                        "The number of columns in the table is not consistent(Headers or Lines)."
6✔
146
                    );
6✔
147
                }
148
            }
149
        }
150
        return true;
135✔
151
    }
152
    #endregion
153

154
    #region Build Methods
155
    private void BuildTable()
156
    {
157
        if (_rawHeaders is null)
540✔
158
        {
159
            if (_rawLines is not null)
30✔
160
            {
161
                BuildLines();
24✔
162
            }
163
        }
164
        else
165
        {
166
            if (_rawLines is null)
510✔
167
            {
168
                BuildHeaders();
48✔
169
            }
170
            else
171
            {
172
                BuildHeadersAndLines();
462✔
173
            }
174
        }
175
    }
468✔
176

177
    private void BuildHeadersAndLines()
178
    {
179
        if (_rawHeaders is not null && _rawLines is not null)
462✔
180
        {
181
            var stringList = new List<string>();
462✔
182
            var localMax = new int[_rawHeaders.Count];
462✔
183
            for (int i = 0; i < _rawHeaders.Count; i++)
3,912✔
184
            {
185
                if (_rawHeaders[i]?.Length > localMax[i])
1,494!
186
                {
187
                    localMax[i] = _rawHeaders[i]?.Length ?? 0;
1,494!
188
                }
189
            }
190

191
            for (int i = 0; i < _rawLines.Count; i++)
5,460✔
192
            {
193
                for (int j = 0; j < _rawLines[i].Count; j++)
18,360✔
194
                {
195
                    if (_rawLines[i][j]?.ToString()?.Length > localMax[j])
6,912!
196
                    {
197
                        localMax[j] = _rawLines[i][j]?.ToString()?.Length ?? 0;
732!
198
                    }
199
                }
200
            }
201

202
            StringBuilder headerBuilder = new("│ ");
462✔
203
            for (int i = 0; i < _rawHeaders.Count; i++)
3,912✔
204
            {
205
                headerBuilder.Append(_rawHeaders[i]?.PadRight(localMax[i]) ?? "");
1,494!
206
                if (i != _rawHeaders.Count - 1)
1,494✔
207
                {
208
                    headerBuilder.Append(" │ ");
1,032✔
209
                }
210
                else
211
                {
212
                    headerBuilder.Append(" │");
462✔
213
                }
214
            }
215
            stringList.Add(headerBuilder.ToString());
462✔
216

217
            StringBuilder upperBorderBuilder = new(GetCorners[0].ToString());
462✔
218
            for (int i = 0; i < _rawHeaders.Count; i++)
3,912✔
219
            {
220
                upperBorderBuilder.Append(new string('─', localMax[i] + 2));
1,494✔
221
                upperBorderBuilder.Append(
1,494✔
222
                    (i != _rawHeaders.Count - 1) ? "┬" : GetCorners[1].ToString()
1,494✔
223
                );
1,494✔
224
            }
225
            stringList.Insert(0, upperBorderBuilder.ToString());
462✔
226

227
            StringBuilder intermediateBorderBuilder = new("├");
462✔
228
            for (int i = 0; i < _rawHeaders.Count; i++)
3,912✔
229
            {
230
                intermediateBorderBuilder.Append(new string('─', localMax[i] + 2));
1,494✔
231
                intermediateBorderBuilder.Append((i != _rawHeaders.Count - 1) ? "┼" : "┤");
1,494✔
232
            }
233
            stringList.Add(intermediateBorderBuilder.ToString());
462✔
234

235
            for (int i = 0; i < _rawLines.Count; i++)
5,460✔
236
            {
237
                StringBuilder lineBuilder = new("│ ");
2,268✔
238
                for (int j = 0; j < _rawLines[i].Count; j++)
18,360✔
239
                {
240
                    lineBuilder.Append(_rawLines[i][j]?.ToString()?.PadRight(localMax[j]) ?? "");
6,912!
241
                    if (j != _rawLines[i].Count - 1)
6,912✔
242
                    {
243
                        lineBuilder.Append(" │ ");
4,644✔
244
                    }
245
                    else
246
                    {
247
                        lineBuilder.Append(" │");
2,268✔
248
                    }
249
                }
250
                stringList.Add(lineBuilder.ToString());
2,268✔
251
            }
252

253
            StringBuilder lowerBorderBuilder = new(GetCorners[2].ToString());
462✔
254
            for (int i = 0; i < _rawHeaders.Count; i++)
3,912✔
255
            {
256
                lowerBorderBuilder.Append(new string('─', localMax[i] + 2));
1,494✔
257
                lowerBorderBuilder.Append(
1,494✔
258
                    (i != _rawHeaders.Count - 1) ? "┴" : GetCorners[3].ToString()
1,494✔
259
                );
1,494✔
260
            }
261
            stringList.Add(lowerBorderBuilder.ToString());
462✔
262

263
            _displayArray = stringList.ToArray();
462✔
264
            BuildTitle();
462✔
265
        }
266
    }
462✔
267

268
    private void BuildHeaders()
269
    {
270
        if (_rawHeaders is not null)
48✔
271
        {
272
            var stringList = new List<string>();
48✔
273
            var localMax = new int[_rawHeaders.Count];
48✔
274
            for (int i = 0; i < _rawHeaders.Count; i++)
600✔
275
            {
276
                if (_rawHeaders[i]?.Length > localMax[i])
252!
277
                {
278
                    localMax[i] = _rawHeaders[i]?.Length ?? 0;
252!
279
                }
280
            }
281
            StringBuilder headerBuilder = new("│ ");
48✔
282
            for (int i = 0; i < _rawHeaders.Count; i++)
600✔
283
            {
284
                headerBuilder.Append(_rawHeaders[i]?.PadRight(localMax[i]) ?? "");
252!
285
                if (i != _rawHeaders.Count - 1)
252✔
286
                {
287
                    headerBuilder.Append(" │ ");
204✔
288
                }
289
                else
290
                {
291
                    headerBuilder.Append(" │");
48✔
292
                }
293
            }
294
            stringList.Add(headerBuilder.ToString());
48✔
295
            StringBuilder upperBorderBuilder = new(GetCorners[0].ToString());
48✔
296
            for (int i = 0; i < _rawHeaders.Count; i++)
600✔
297
            {
298
                upperBorderBuilder.Append(new string('─', localMax[i] + 2));
252✔
299
                upperBorderBuilder.Append(
252✔
300
                    (i != _rawHeaders.Count - 1) ? "┬" : GetCorners[1].ToString()
252✔
301
                );
252✔
302
            }
303
            stringList.Insert(0, upperBorderBuilder.ToString());
48✔
304
            StringBuilder lowerBorderBuilder = new(GetCorners[2].ToString());
48✔
305
            for (int i = 0; i < _rawHeaders.Count; i++)
600✔
306
            {
307
                lowerBorderBuilder.Append(new string('─', localMax[i] + 2));
252✔
308
                lowerBorderBuilder.Append(
252✔
309
                    (i != _rawHeaders.Count - 1) ? "┴" : GetCorners[3].ToString()
252✔
310
                );
252✔
311
            }
312
            stringList.Add(lowerBorderBuilder.ToString());
48✔
313
            _displayArray = stringList.ToArray();
48✔
314
            BuildTitle();
48✔
315
        }
316
    }
48✔
317

318
    private void BuildLines()
319
    {
320
        if (_rawLines is not null)
24✔
321
        {
322
            var stringList = new List<string>();
24✔
323
            var localMax = new int[_rawLines[0].Count];
24✔
324
            for (int i = 0; i < _rawLines.Count; i++)
132✔
325
            {
326
                for (int j = 0; j < _rawLines[i].Count; j++)
336✔
327
                {
328
                    if (_rawLines[i][j]?.ToString()?.Length > localMax[j])
126!
329
                    {
330
                        localMax[j] = _rawLines[i][j]?.ToString()?.Length ?? 0;
72!
331
                    }
332
                }
333
            }
334
            for (int i = 0; i < _rawLines.Count; i++)
132✔
335
            {
336
                StringBuilder line = new("│ ");
42✔
337
                for (int j = 0; j < _rawLines[i].Count; j++)
336✔
338
                {
339
                    line.Append(_rawLines[i][j]?.ToString()?.PadRight(localMax[j]) ?? "");
126!
340
                    if (j != _rawLines[i].Count - 1)
126✔
341
                    {
342
                        line.Append(" │ ");
84✔
343
                    }
344
                    else
345
                    {
346
                        line.Append(" │");
42✔
347
                    }
348
                }
349
                stringList.Add(line.ToString());
42✔
350
            }
351
            StringBuilder upperBorderBuilder = new(GetCorners[0].ToString());
24✔
352
            for (int i = 0; i < _rawLines.Count; i++)
132✔
353
            {
354
                upperBorderBuilder.Append(new string('─', localMax[i] + 2));
42✔
355
                upperBorderBuilder.Append(
42✔
356
                    (i != _rawLines.Count - 1) ? "┬" : GetCorners[1].ToString()
42✔
357
                );
42✔
358
            }
359
            stringList.Insert(0, upperBorderBuilder.ToString());
24✔
360
            StringBuilder lowerBorderBuilder = new(GetCorners[2].ToString());
24✔
361
            for (int i = 0; i < _rawLines.Count; i++)
132✔
362
            {
363
                lowerBorderBuilder.Append(new string('─', localMax[i] + 2));
42✔
364
                lowerBorderBuilder.Append(
42✔
365
                    (i != _rawLines.Count - 1) ? "┴" : GetCorners[3].ToString()
42✔
366
                );
42✔
367
            }
368
            stringList.Add(lowerBorderBuilder.ToString());
24✔
369
            _displayArray = stringList.ToArray();
24✔
370
            BuildTitle();
24✔
371
        }
372
    }
24✔
373

374
    private void BuildTitle()
375
    {
376
        if (_title is not null)
534✔
377
        {
378
            var len = _displayArray![0].Length;
366✔
379
            var title = _title.ResizeString(len - 4);
366✔
380
            title = $"│ {title} │";
366✔
381
            var upperBorderBuilder = new StringBuilder(GetCorners[0].ToString());
366✔
382
            upperBorderBuilder.Append(new string('─', len - 2));
366✔
383
            upperBorderBuilder.Append(GetCorners[1].ToString());
366✔
384
            var display = _displayArray.ToList();
366✔
385
            display[0] = display[0]
366✔
386
                .Remove(0, 1)
366✔
387
                .Insert(0, "├")
366✔
388
                .Remove(display[1].Length - 1, 1)
366✔
389
                .Insert(display[1].Length - 1, "┤");
366✔
390
            display.Insert(0, title);
366✔
391
            display.Insert(0, upperBorderBuilder.ToString());
366✔
392
            _displayArray = display.ToArray();
366✔
393
        }
394
    }
534✔
395
    #endregion
396

397
    #region Properties: GetCorners, Count
398
    private string GetCorners => _roundedCorners ? "╭╮╰╯" : "┌┐└┘";
2,868✔
399

400
    /// <summary>
401
    /// This property returns the number of lines in the table.
402
    /// </summary>
403
    public int Count => _rawLines?.Count ?? 0;
24✔
404

405
    #endregion
406

407
    #region Methods: Get, Add, Update, Remove, Clear
408
    /// <summary>
409
    /// Toggles the rounded corners of the table.
410
    /// </summary>
411
    /// <remarks>Refer to the example project to understand how to implement it available at https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs </remarks>
412
    public void SetRoundedCorners(bool rounded = true)
413
    {
414
        _roundedCorners = rounded;
6✔
415
        BuildTable();
6✔
416
    }
6✔
417

418
    /// <summary>
419
    /// This method adds a title to the table.
420
    /// </summary>
421
    /// <param name="title">The title to add.</param>
422
    public void AddTitle(string title)
423
    {
424
        _title = title;
6✔
425
        BuildTable();
6✔
426
    }
6✔
427

428
    /// <summary>
429
    /// This method updates the title of the table.
430
    /// </summary>
431
    /// <param name="title">The title to update.</param>
432
    public void UpdateTitle(string title)
433
    {
434
        AddTitle(title);
3✔
435
    }
3✔
436

437
    /// <summary>
438
    /// This method clears the title of the table.
439
    /// </summary>
440
    public void ClearTitle()
441
    {
442
        _title = null;
9✔
443
        BuildTable();
9✔
444
    }
9✔
445

446
    /// <summary>
447
    /// This method adds headers to the table.
448
    /// </summary>
449
    /// <param name="headers">The headers to add.</param>
450
    public void AddHeaders(List<string> headers)
451
    {
452
        _rawHeaders = headers;
9✔
453
        if (CompatibilityCheck())
9✔
454
        {
455
            BuildTable();
6✔
456
        }
457
    }
6✔
458

459
    /// <summary>
460
    /// This method updates the headers of the table.
461
    /// </summary>
462
    /// <param name="headers">The headers to update.</param>
463
    public void UpdateHeaders(List<string> headers)
464
    {
465
        AddHeaders(headers);
3✔
466
    }
3✔
467

468
    /// <summary>
469
    /// This method clears the headers of the table.
470
    /// </summary>
471
    public void ClearHeaders()
472
    {
473
        _rawHeaders = null;
12✔
474
        BuildTable();
12✔
475
    }
12✔
476

477
    /// <summary>
478
    /// This method adds a line to the table.
479
    /// </summary>
480
    /// <param name="line">The line to add.</param>
481
    /// <exception cref="ArgumentException">Is thrown when the number of columns in the table is not consistent with itself or with the headers.</exception>
482
    /// <remarks>Refer to the example project to understand how to implement it available at https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs </remarks>
483
    public void AddLine(List<T> line)
484
    {
485
        if (_rawLines?.Count > 0 && line.Count != _rawLines[0].Count)
306✔
486
        {
487
            throw new ArgumentException(
3✔
488
                "The number of columns in the table is not consistent with other lines."
3✔
489
            );
3✔
490
        }
491
        if (_rawHeaders is not null && line.Count != _rawHeaders.Count)
303✔
492
        {
493
            throw new ArgumentException(
3✔
494
                "The number of columns in the table is not consistent with the headers."
3✔
495
            );
3✔
496
        }
497
        _rawLines ??= new List<List<T>>();
300✔
498
        _rawLines.Add(line);
300✔
499
        BuildTable();
300✔
500
    }
300✔
501

502
    /// <summary>
503
    /// This method updates a line in the table.
504
    /// </summary>
505
    /// <param name="index">The index of the line to update.</param>
506
    /// <param name="line">The new line.</param>
507
    /// <exception cref="ArgumentOutOfRangeException">Is thrown when the index is out of range.</exception>
508
    /// <exception cref="ArgumentException">Is thrown when the number of columns in the table is not consistent with itself or with the headers.</exception>
509
    /// <remarks>Refer to the example project to understand how to implement it available at https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs </remarks>
510
    public void UpdateLine(int index, List<T> line)
511
    {
512
        if (_rawLines?.Count > 0)
9!
513
        {
514
            if (index < 0 || index >= _rawLines.Count)
9✔
515
            {
516
                throw new ArgumentOutOfRangeException(nameof(index), "The index is out of range.");
3✔
517
            }
518

519
            if (line.Count != _rawHeaders?.Count)
6!
520
            {
521
                throw new ArgumentException(
3✔
522
                    "The number of columns in the table is not consistent."
3✔
523
                );
3✔
524
            }
525
        }
526
        _rawLines![index] = line;
3✔
527
        BuildTable();
3✔
528
    }
3✔
529

530
    /// <summary>
531
    /// This method removes a line from the table.
532
    /// </summary>
533
    /// <param name="index">The index of the line to remove.</param>
534
    /// <exception cref="ArgumentOutOfRangeException">Is thrown when the index is out of range.</exception>
535
    /// <remarks>Refer to the example project to understand how to implement it available at https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs </remarks>
536
    public void RemoveLine(int index)
537
    {
538
        if (_rawLines?.Count > 0 && (index < 0 || index >= _rawLines.Count))
6!
539
        {
540
            throw new ArgumentOutOfRangeException(nameof(index), "The index is out of range.");
3✔
541
        }
542

543
        _rawLines?.RemoveAt(index);
3!
544
        BuildTable();
3✔
545
    }
3✔
546

547
    /// <summary>
548
    /// This method clears the lines of the table.
549
    /// </summary>
550
    public void ClearLines()
551
    {
552
        _rawLines = null;
9✔
553
        BuildTable();
9✔
554
    }
9✔
555

556
    /// <summary>
557
    /// This property returns the specified line in the table.
558
    /// </summary>
559
    /// <param name="index">The index of the line to return.</param>
560
    /// <returns>The line at the specified index.</returns>
561
    /// <exception cref="ArgumentOutOfRangeException">Is thrown when the index is out of range.</exception>
562
    /// <remarks>Refer to the example project to understand how to implement it available at https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs </remarks>
563
    public List<T> GetLine(int index)
564
    {
565
        if (index < 0 || index >= _rawLines?.Count)
9!
566
        {
567
            throw new ArgumentOutOfRangeException(nameof(index), "The index is out of range.");
3✔
568
        }
569
        return _rawLines![index];
6✔
570
    }
571

572
    /// <summary>
573
    /// This method is used to get all the elements from a column given its index.
574
    /// </summary>
575
    /// <param name="index">The index of the column.</param>
576
    /// <returns>The elements of the column.</returns>
577
    /// <exception cref="ArgumentOutOfRangeException">Is thrown when the index is out of range.</exception>
578
    public List<T>? GetColumnData(int index)
579
    {
580
        if (_rawLines is null)
21✔
581
        {
582
            return null;
3✔
583
        }
584

585
        if (index < 0 || index >= _rawLines[0].Count)
18✔
586
        {
587
            throw new ArgumentOutOfRangeException(nameof(index), "Invalid column index.");
3✔
588
        }
589

590
        List<T>? list = new();
15✔
591
        for (int i = 0; i < _rawLines.Count; i++)
198✔
592
        {
593
            list.Add(_rawLines[i][index]);
84✔
594
        }
595
        return list;
15✔
596
    }
597

598
    /// <summary>
599
    /// This method is used to get all the elements from a column given its header.
600
    /// </summary>
601
    /// <param name="header">The header of the column.</param>
602
    /// <returns>The elements of the column.</returns>
603
    /// <exception cref="InvalidOperationException">Is thrown when the table is empty.</exception>
604
    /// <exception cref="ArgumentOutOfRangeException">Is thrown when the header is invalid.</exception>
605
    public List<T>? GetColumnData(string header)
606
    {
607
        if (_rawHeaders is null)
21✔
608
        {
609
            throw new InvalidOperationException("The headers are null.");
3✔
610
        }
611
        else if (_rawLines is null)
18✔
612
        {
613
            return null;
3✔
614
        }
615
        if (!_rawHeaders.Contains(header))
15✔
616
        {
617
            throw new ArgumentOutOfRangeException(nameof(header), "Invalid column header.");
3✔
618
        }
619

620
        return GetColumnData(_rawHeaders.IndexOf(header));
12✔
621
    }
622

623
    /// <summary>
624
    /// This method clears the table.
625
    /// </summary>
626
    public void Reset()
627
    {
628
        _title = null;
3✔
629
        _rawHeaders?.Clear();
3!
630
        _rawLines?.Clear();
3!
631
        _displayArray = null;
3✔
632
    }
3✔
633
    #endregion
634

635
    #region Display Methods
636
    /// <summary>
637
    /// This method displays the table without interaction.
638
    /// </summary>
639
    protected override void RenderElementActions()
640
    {
641
        string[] array = new string[_displayArray!.Length];
3✔
642
        for (int j = 0; j < _displayArray.Length; j++)
54✔
643
        {
644
            array[j] = _displayArray[j];
24✔
645
            Core.WritePositionedString(array[j], _placement.ToTextAlignment(), false, _line + j);
24✔
646
        }
647
    }
3✔
648
    #endregion
649
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc