Skip to content

Commit 0ab61a7

Browse files
committed
Minor tidy up
* Makes private `CsvField.PickValue` setter public * Adds constructor overloads for `CsvField` for all members
1 parent e3ed9ec commit 0ab61a7

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

CSharpVitamins.Tabulation/CSharpVitamins.Tabulation.nuspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
`CharpVitamins.Tabulation` provides helpers to create tabular data with little fuss i.e. Tab or comma separated values (`CsvDefinition`),
1313
or padded columns of plain text (via `PlainTextTable`).</description>
1414
<releaseNotes>
15+
* 2.0.1: Makes private `CsvField.PickValue` setter public
16+
Adds constructor overloads for `CsvField` for all members
1517
* 2.0.0: Breaking: changes `CsvDefinition` from a `KeyValuePair&lt;string, Func&lt;T, string&gt;&gt;` to a custom `CsvField&lt;T&gt;` for simplicity to add more functionailty.
1618
Adds option for overiding a label on `CsvDefinition` fields (key and label can now be different)
1719
Adds option to provide an include function, to determine if the column should render or not (allows for simpler conditionally included columns)

CSharpVitamins.Tabulation/CsvDefinition.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void Add(string key, Func<T, string> picker)
7676
/// <param name="picker"></param>
7777
public void Add(string key, string label, Func<T, string> picker)
7878
{
79-
Add(new CsvField<T>(key, picker) { Label = label });
79+
Add(new CsvField<T>(key, label, picker));
8080
}
8181

8282
/// <summary>
@@ -88,7 +88,7 @@ public void Add(string key, string label, Func<T, string> picker)
8888
/// <param name="include"></param>
8989
public void Add(string key, Func<T, string> picker, Func<string, bool> include)
9090
{
91-
Add(new CsvField<T>(key, picker) { Include = include, });
91+
Add(new CsvField<T>(key, label: null, picker: picker, include: include));
9292
}
9393

9494
/// <summary>
@@ -100,7 +100,7 @@ public void Add(string key, Func<T, string> picker, Func<string, bool> include)
100100
/// <param name="include"></param>
101101
public void Add(string key, string label, Func<T, string> picker, Func<string, bool> include)
102102
{
103-
Add(new CsvField<T>(key, picker) { Label = label, Include = include, });
103+
Add(new CsvField<T>(key, label, picker, include));
104104
}
105105

106106
/// <summary>

CSharpVitamins.Tabulation/CsvField.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class CsvField<T>
1717
/// <summary>
1818
/// The converter function used to produce a cell's string from the row object
1919
/// </summary>
20-
public Func<T, string> PickValue { get; private set; }
20+
public Func<T, string> PickValue { get; set; }
2121

2222
/// <summary>
2323
/// The column label to use. If null (default) uses the current `Key`. Can be an empty string to prevent a label from showing.
@@ -49,6 +49,20 @@ public CsvField(string key, Func<T, string> picker)
4949
this.PickValue = picker;
5050
}
5151

52+
/// <summary>
53+
///
54+
/// </summary>
55+
/// <param name="key"></param>
56+
/// <param name="label"></param>
57+
/// <param name="picker"></param>
58+
/// <param name="include"></param>
59+
public CsvField(string key, string label, Func<T, string> picker, Func<string, bool> include = null)
60+
: this(key, picker)
61+
{
62+
this.Label = label;
63+
this.Include = include;
64+
}
65+
5266
/// <summary>
5367
/// If the field should be included in the output - see `.Include` for defineing func
5468
/// </summary>
@@ -66,6 +80,6 @@ public static implicit operator KeyValuePair<string, Func<T, string>>(CsvField<T
6680
/// </summary>
6781
/// <param name="pair"></param>
6882
public static implicit operator CsvField<T>(KeyValuePair<string, Func<T, string>> pair)
69-
=> new CsvField<T>(pair.Key, pair.Value);
83+
=> new CsvField<T>(key: pair.Key, picker: pair.Value);
7084
}
7185
}

CSharpVitamins.Tabulation/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
[assembly: ComVisible(false)]
1515
[assembly: Guid("09a98341-8845-4307-b4e4-5235b3cf9191")]
1616

17-
[assembly: AssemblyVersion("2.0.0")]
18-
[assembly: AssemblyFileVersion("2.0.0")]
17+
[assembly: AssemblyVersion("2.0.1")]
18+
[assembly: AssemblyFileVersion("2.0.1")]

0 commit comments

Comments
 (0)