Skip to content

Commit 3a5ee99

Browse files
committed
code format
1 parent 72c2380 commit 3a5ee99

File tree

9 files changed

+87
-76
lines changed

9 files changed

+87
-76
lines changed

sources/ConsoleTools/ConsoleTools/MultilineText.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class MultilineText : IEnumerable<string>
3838
public string RawText { get; }
3939

4040
/// <summary>
41-
/// Gets the text splitted in lines.
41+
/// Gets the text split in lines.
4242
/// </summary>
4343
public ReadOnlyCollection<string> Lines { get; }
4444

@@ -58,7 +58,7 @@ public class MultilineText : IEnumerable<string>
5858
public bool IsEmpty => Size.IsEmpty;
5959

6060
/// <summary>
61-
/// Used only internaly when splitting the string in multiple lines.
61+
/// Used only internally when splitting the string in multiple lines.
6262
/// </summary>
6363
private enum LineEndChar
6464
{

sources/ConsoleTools/ConsoleTools/TabularData/CellBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ protected CellBase(object content, HorizontalAlignment horizontalAlignment = Hor
9090
/// <summary>
9191
/// Returns the size of the cell, including the padding.
9292
/// </summary>
93-
public Size CalculatePreferedSize()
93+
public Size CalculatePreferredSize()
9494
{
9595
int cellWidth;
9696
int cellHeight;
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,59 @@
1-
// ConsoleTools
2-
// Copyright (C) 2017-2018 Dust in the Wind
3-
//
4-
// This program is free software: you can redistribute it and/or modify
5-
// it under the terms of the GNU General Public License as published by
6-
// the Free Software Foundation, either version 3 of the License, or
7-
// (at your option) any later version.
8-
//
9-
// This program is distributed in the hope that it will be useful,
10-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
// GNU General Public License for more details.
13-
//
14-
// You should have received a copy of the GNU General Public License
15-
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
17-
// --------------------------------------------------------------------------------
18-
// Bugs or feature requests
19-
// --------------------------------------------------------------------------------
20-
// Note: For any bug or feature request please add a new issue on GitHub: https://github.com/lastunicorn/ConsoleTools/issues/new
21-
22-
using System;
23-
using System.Collections.Generic;
24-
25-
namespace DustInTheWind.ConsoleTools.TabularData.RenderingModel
26-
{
27-
internal class BottomBorderData
28-
{
29-
private readonly BorderTemplate borderTemplate;
30-
private string borderText;
31-
private List<int> columnsWidths;
32-
33-
public List<int> ColumnsWidths
34-
{
35-
get { return columnsWidths; }
36-
set
37-
{
38-
if (value == columnsWidths)
39-
return;
40-
41-
columnsWidths = value;
42-
borderText = null;
43-
}
44-
}
45-
46-
public BottomBorderData(BorderTemplate borderTemplate)
47-
{
48-
if (borderTemplate == null) throw new ArgumentNullException(nameof(borderTemplate));
49-
this.borderTemplate = borderTemplate;
50-
}
51-
52-
public void Render(ITablePrinter tablePrinter)
53-
{
54-
if (borderText == null)
55-
borderText = borderTemplate.GenerateBottomBorder(columnsWidths);
56-
57-
tablePrinter.WriteLineBorder(borderText);
58-
}
59-
}
1+
// ConsoleTools
2+
// Copyright (C) 2017-2018 Dust in the Wind
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
// --------------------------------------------------------------------------------
18+
// Bugs or feature requests
19+
// --------------------------------------------------------------------------------
20+
// Note: For any bug or feature request please add a new issue on GitHub: https://github.com/lastunicorn/ConsoleTools/issues/new
21+
22+
using System;
23+
using System.Collections.Generic;
24+
25+
namespace DustInTheWind.ConsoleTools.TabularData.RenderingModel
26+
{
27+
internal class DataBottomBorder
28+
{
29+
private readonly BorderTemplate borderTemplate;
30+
private string borderText;
31+
private List<int> columnsWidths;
32+
33+
public List<int> ColumnsWidths
34+
{
35+
get => columnsWidths;
36+
set
37+
{
38+
if (value == columnsWidths)
39+
return;
40+
41+
columnsWidths = value;
42+
borderText = null;
43+
}
44+
}
45+
46+
public DataBottomBorder(BorderTemplate borderTemplate)
47+
{
48+
this.borderTemplate = borderTemplate ?? throw new ArgumentNullException(nameof(borderTemplate));
49+
}
50+
51+
public void Render(ITablePrinter tablePrinter)
52+
{
53+
if (borderText == null)
54+
borderText = borderTemplate.GenerateBottomBorder(columnsWidths);
55+
56+
tablePrinter.WriteLineBorder(borderText);
57+
}
58+
}
6059
}

sources/ConsoleTools/ConsoleTools/TabularData/RenderingModel/DataGridX.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ internal class DataGridX
4747
public HeaderBottomBorder HeaderBottomBorder { get; set; }
4848

4949
public DataDataSeparator DataDataSeparator { get; set; }
50-
public BottomBorderData DataBottomBorder { get; set; }
50+
public DataBottomBorder DataBottomBorder { get; set; }
5151

5252
public DataGridX(bool displayBorder)
5353
{
@@ -143,28 +143,43 @@ public void MakeFinalAdjustments()
143143
}
144144

145145
public void Render(ITablePrinter tablePrinter)
146+
{
147+
RenderTitle(tablePrinter);
148+
RenderHeader(tablePrinter);
149+
RenderData(tablePrinter);
150+
}
151+
152+
private void RenderTitle(ITablePrinter tablePrinter)
146153
{
147154
TitleTopBorder?.Render(tablePrinter);
148-
HeaderTopBorder?.Render(tablePrinter);
149-
DataTopBorder?.Render(tablePrinter);
150155

151156
titleRowX?.Render(tablePrinter);
152157

153158
TitleHeaderSeparator?.Render(tablePrinter);
154159
TitleDataSeparator?.Render(tablePrinter);
155160
TitleBottomBorder?.Render(tablePrinter);
161+
}
162+
163+
private void RenderHeader(ITablePrinter tablePrinter)
164+
{
165+
HeaderTopBorder?.Render(tablePrinter);
156166

157167
headerRowX?.Render(tablePrinter, columnsWidths);
158168

159169
HeaderDataSeparator?.Render(tablePrinter);
160170
HeaderBottomBorder?.Render(tablePrinter);
171+
}
172+
173+
private void RenderData(ITablePrinter tablePrinter)
174+
{
175+
DataTopBorder?.Render(tablePrinter);
161176

162177
RenderDataRows(tablePrinter);
163178

164179
DataBottomBorder?.Render(tablePrinter);
165180
}
166181

167-
public void RenderDataRows(ITablePrinter tablePrinter)
182+
private void RenderDataRows(ITablePrinter tablePrinter)
168183
{
169184
List<int> cellWidths = columnsWidths;
170185

sources/ConsoleTools/ConsoleTools/TabularData/RenderingModel/DataGridXBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private void AddHorizontalBorders()
126126
if (DisplayBorderBetweenRows)
127127
dataGridX.DataDataSeparator = new DataDataSeparator(BorderTemplate);
128128

129-
dataGridX.DataBottomBorder = new BottomBorderData(BorderTemplate);
129+
dataGridX.DataBottomBorder = new DataBottomBorder(BorderTemplate);
130130
}
131131
}
132132
}

sources/ConsoleTools/ConsoleTools/TabularData/RenderingModel/DataRowX.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ internal class DataRowX
3434

3535
public DataRowX(DataRow dataRow, bool hasBorder)
3636
{
37-
if (dataRow == null) throw new ArgumentNullException(nameof(dataRow));
38-
39-
this.dataRow = dataRow;
37+
this.dataRow = dataRow ?? throw new ArgumentNullException(nameof(dataRow));
4038
this.hasBorder = hasBorder;
4139

4240
CreateCells();
@@ -50,7 +48,7 @@ private void CreateCells()
5048
{
5149
DataCellX cell = new DataCellX
5250
{
53-
Size = dataRow[i].CalculatePreferedSize()
51+
Size = dataRow[i].CalculatePreferredSize()
5452
};
5553

5654
AddCellToSize(cell);

sources/ConsoleTools/ConsoleTools/TabularData/RenderingModel/HeaderRowX.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private void CreateCells()
4848
{
4949
DataCellX cell = new DataCellX
5050
{
51-
Size = column.HeaderCell.CalculatePreferedSize()
51+
Size = column.HeaderCell.CalculatePreferredSize()
5252
};
5353

5454
AddCellToSize(cell);

sources/ConsoleTools/ConsoleTools/TabularData/RenderingModel/HeaderTopBorder.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ internal class HeaderTopBorder
3232

3333
public List<int> ColumnsWidths
3434
{
35-
get { return columnsWidths; }
35+
get => columnsWidths;
3636
set
3737
{
3838
if (value == columnsWidths)
@@ -45,8 +45,7 @@ public List<int> ColumnsWidths
4545

4646
public HeaderTopBorder(BorderTemplate borderTemplate)
4747
{
48-
if (borderTemplate == null) throw new ArgumentNullException(nameof(borderTemplate));
49-
this.borderTemplate = borderTemplate;
48+
this.borderTemplate = borderTemplate ?? throw new ArgumentNullException(nameof(borderTemplate));
5049
}
5150

5251
public void Render(ITablePrinter tablePrinter)

sources/ConsoleTools/ConsoleTools/TabularData/TitleRow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public Size CalculatePreferredSize()
119119
if (displayBorder)
120120
titleRowWidth += 1;
121121

122-
Size cellSize = TitleCell.CalculatePreferedSize();
122+
Size cellSize = TitleCell.CalculatePreferredSize();
123123
titleRowWidth += cellSize.Width;
124124

125125
if (displayBorder)

0 commit comments

Comments
 (0)