Skip to content

Commit

Permalink
Allow explicitly writing schema using typed writers.
Browse files Browse the repository at this point in the history
  • Loading branch information
jehugaleahsa committed Oct 7, 2020
1 parent 6f5dcd1 commit a0d9760
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 4.10.0 (2020-10-06)
**Summary** - Add the ability to explicitly write the schema using typed writers.

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.

## 4.9.0 (2020-09-26)
**Summary** - Make OnParsing, OnParsed, OnFormatting, OnFormatted events available to type mappings.

Expand Down
8 changes: 4 additions & 4 deletions FlatFiles/FlatFiles.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
<RepositoryUrl>https://github.com/jehugaleahsa/FlatFiles.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>csv;comma;tab;separated;value;delimited;flat;file;fixed;width;fixed-width;length;fixed-length;parser;parsing;parse</PackageTags>
<PackageReleaseNotes>Allowing configuring OnParsing, OnParsed, OnFormatting, OnFormatted events with type mappings. Raise events when processing ignored columns.</PackageReleaseNotes>
<PackageReleaseNotes>Allow explicitly writing the schema using typed mappers.</PackageReleaseNotes>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>FlatFiles.snk</AssemblyOriginatorKeyFile>
<Version>4.9.0</Version>
<Version>4.10.0</Version>
</PropertyGroup>

<PropertyGroup>
<LangVersion>8.0</LangVersion>
<PackageIconUrl></PackageIconUrl>
<AssemblyVersion>4.9.0.0</AssemblyVersion>
<FileVersion>4.9.0.0</FileVersion>
<AssemblyVersion>4.10.0.0</AssemblyVersion>
<FileVersion>4.10.0.0</FileVersion>
<PackageLicenseFile>UNLICENSE.txt</PackageLicenseFile>
<PackageIcon>icon.png</PackageIcon>
</PropertyGroup>
Expand Down
12 changes: 12 additions & 0 deletions FlatFiles/IWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ public interface IWriter
/// <returns>The schema being used by the builder to create the textual representation.</returns>
ISchema GetSchema();

/// <summary>
/// Write the textual representation of the record schema.
/// </summary>
/// <remarks>If the header or records have already been written, this call is ignored.</remarks>
void WriteSchema();

/// <summary>
/// Write the textual representation of the record schema.
/// </summary>
/// <remarks>If the header or records have already been written, this call is ignored.</remarks>
Task WriteSchemaAsync();

/// <summary>
/// Writes the textual representation of the given values to the writer.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion FlatFiles/SeparatedValueWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ ISchema IWriter.GetSchema()
}

/// <summary>
/// Write the textual representation of the record schema to the writer.
/// Write the textual representation of the record schema.
/// </summary>
/// <remarks>If the header or records have already been written, this call is ignored.</remarks>
public void WriteSchema()
Expand Down
32 changes: 32 additions & 0 deletions FlatFiles/TypeMapping/TypedWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ public interface ITypedWriter<TEntity>
/// <returns>The schema being used by the writer.</returns>
ISchema GetSchema();

/// <summary>
/// Write the textual representation of the record schema.
/// </summary>
/// <remarks>If the header or records have already been written, this call is ignored.</remarks>
void WriteSchema();

/// <summary>
/// Write the textual representation of the record schema to the writer.
/// </summary>
/// <remarks>If the header or records have already been written, this call is ignored.</remarks>
Task WriteSchemaAsync();

/// <summary>
/// Writes the given entity to the underlying document.
/// </summary>
Expand Down Expand Up @@ -84,6 +96,16 @@ public ISchema GetSchema()
return writer.GetSchema();
}

public void WriteSchema()
{
writer.WriteSchema();
}

public async Task WriteSchemaAsync()
{
await writer.WriteSchemaAsync().ConfigureAwait(false);
}

public void Write(TEntity entity)
{
var values = Serialize(entity);
Expand Down Expand Up @@ -146,6 +168,16 @@ public ISchema GetSchema()
return null;
}

public void WriteSchema()
{
writer.WriteSchema();
}

public async Task WriteSchemaAsync()
{
await writer.WriteSchemaAsync().ConfigureAwait(false);
}

public void Write(object entity)
{
var values = Serialize(entity);
Expand Down
10 changes: 10 additions & 0 deletions FlatFiles/TypeMapping/UntypedWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ public ISchema GetSchema()
return writer.GetSchema();
}

public void WriteSchema()
{
writer.WriteSchema();
}

public async Task WriteSchemaAsync()
{
await writer.WriteSchemaAsync().ConfigureAwait(false);
}

public void Write(object entity)
{
writer.Write((TEntity)entity);
Expand Down

0 comments on commit a0d9760

Please sign in to comment.