Skip to content

Commit a0d9760

Browse files
committed
Allow explicitly writing schema using typed writers.
1 parent 6f5dcd1 commit a0d9760

File tree

6 files changed

+64
-5
lines changed

6 files changed

+64
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 4.10.0 (2020-10-06)
2+
**Summary** - Add the ability to explicitly write the schema using typed writers.
3+
4+
I never added support for writing the schema using typed writers. I never added `WriteSchema` and `WriteSchemaAsync` to the `IWriter` interface either. I don't see why not, so I added them.
5+
16
## 4.9.0 (2020-09-26)
27
**Summary** - Make OnParsing, OnParsed, OnFormatting, OnFormatted events available to type mappings.
38

FlatFiles/FlatFiles.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
<RepositoryUrl>https://github.com/jehugaleahsa/FlatFiles.git</RepositoryUrl>
1111
<RepositoryType>git</RepositoryType>
1212
<PackageTags>csv;comma;tab;separated;value;delimited;flat;file;fixed;width;fixed-width;length;fixed-length;parser;parsing;parse</PackageTags>
13-
<PackageReleaseNotes>Allowing configuring OnParsing, OnParsed, OnFormatting, OnFormatted events with type mappings. Raise events when processing ignored columns.</PackageReleaseNotes>
13+
<PackageReleaseNotes>Allow explicitly writing the schema using typed mappers.</PackageReleaseNotes>
1414
<SignAssembly>true</SignAssembly>
1515
<AssemblyOriginatorKeyFile>FlatFiles.snk</AssemblyOriginatorKeyFile>
16-
<Version>4.9.0</Version>
16+
<Version>4.10.0</Version>
1717
</PropertyGroup>
1818

1919
<PropertyGroup>
2020
<LangVersion>8.0</LangVersion>
2121
<PackageIconUrl></PackageIconUrl>
22-
<AssemblyVersion>4.9.0.0</AssemblyVersion>
23-
<FileVersion>4.9.0.0</FileVersion>
22+
<AssemblyVersion>4.10.0.0</AssemblyVersion>
23+
<FileVersion>4.10.0.0</FileVersion>
2424
<PackageLicenseFile>UNLICENSE.txt</PackageLicenseFile>
2525
<PackageIcon>icon.png</PackageIcon>
2626
</PropertyGroup>

FlatFiles/IWriter.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ public interface IWriter
2424
/// <returns>The schema being used by the builder to create the textual representation.</returns>
2525
ISchema GetSchema();
2626

27+
/// <summary>
28+
/// Write the textual representation of the record schema.
29+
/// </summary>
30+
/// <remarks>If the header or records have already been written, this call is ignored.</remarks>
31+
void WriteSchema();
32+
33+
/// <summary>
34+
/// Write the textual representation of the record schema.
35+
/// </summary>
36+
/// <remarks>If the header or records have already been written, this call is ignored.</remarks>
37+
Task WriteSchemaAsync();
38+
2739
/// <summary>
2840
/// Writes the textual representation of the given values to the writer.
2941
/// </summary>

FlatFiles/SeparatedValueWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ ISchema IWriter.GetSchema()
108108
}
109109

110110
/// <summary>
111-
/// Write the textual representation of the record schema to the writer.
111+
/// Write the textual representation of the record schema.
112112
/// </summary>
113113
/// <remarks>If the header or records have already been written, this call is ignored.</remarks>
114114
public void WriteSchema()

FlatFiles/TypeMapping/TypedWriter.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ public interface ITypedWriter<TEntity>
3232
/// <returns>The schema being used by the writer.</returns>
3333
ISchema GetSchema();
3434

35+
/// <summary>
36+
/// Write the textual representation of the record schema.
37+
/// </summary>
38+
/// <remarks>If the header or records have already been written, this call is ignored.</remarks>
39+
void WriteSchema();
40+
41+
/// <summary>
42+
/// Write the textual representation of the record schema to the writer.
43+
/// </summary>
44+
/// <remarks>If the header or records have already been written, this call is ignored.</remarks>
45+
Task WriteSchemaAsync();
46+
3547
/// <summary>
3648
/// Writes the given entity to the underlying document.
3749
/// </summary>
@@ -84,6 +96,16 @@ public ISchema GetSchema()
8496
return writer.GetSchema();
8597
}
8698

99+
public void WriteSchema()
100+
{
101+
writer.WriteSchema();
102+
}
103+
104+
public async Task WriteSchemaAsync()
105+
{
106+
await writer.WriteSchemaAsync().ConfigureAwait(false);
107+
}
108+
87109
public void Write(TEntity entity)
88110
{
89111
var values = Serialize(entity);
@@ -146,6 +168,16 @@ public ISchema GetSchema()
146168
return null;
147169
}
148170

171+
public void WriteSchema()
172+
{
173+
writer.WriteSchema();
174+
}
175+
176+
public async Task WriteSchemaAsync()
177+
{
178+
await writer.WriteSchemaAsync().ConfigureAwait(false);
179+
}
180+
149181
public void Write(object entity)
150182
{
151183
var values = Serialize(entity);

FlatFiles/TypeMapping/UntypedWriter.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ public ISchema GetSchema()
3737
return writer.GetSchema();
3838
}
3939

40+
public void WriteSchema()
41+
{
42+
writer.WriteSchema();
43+
}
44+
45+
public async Task WriteSchemaAsync()
46+
{
47+
await writer.WriteSchemaAsync().ConfigureAwait(false);
48+
}
49+
4050
public void Write(object entity)
4151
{
4252
writer.Write((TEntity)entity);

0 commit comments

Comments
 (0)