-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from jonsagara/feature/classes
BarcodeParseResult now has an Errors property
- Loading branch information
Showing
7 changed files
with
149 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
namespace IdParser.Core; | ||
|
||
/// <summary> | ||
/// Contains the result of parsing a scanned ID: the ID card, a collection of unhandled fields, and any | ||
/// field-level parsing errors that occurred. | ||
/// </summary> | ||
public class BarcodeParseResult | ||
{ | ||
/// <summary> | ||
/// Contains values of any elements extracted from the scanned ID text. | ||
/// </summary> | ||
public IdentificationCard Card { get; } | ||
|
||
/// <summary> | ||
/// Contains any unhandled element IDs and their raw values. | ||
/// </summary> | ||
public IReadOnlyCollection<UnhandledElement> UnhandledElements { get; } | ||
|
||
/// <summary> | ||
/// Contains errors that occurred while trying to parse the scanned ID text. | ||
/// </summary> | ||
public IReadOnlyCollection<ParseError> Errors { get; } | ||
|
||
|
||
internal BarcodeParseResult(IdentificationCard card, IReadOnlyCollection<UnhandledElement> unhandledElements, IReadOnlyCollection<ParseError> errors) | ||
{ | ||
ArgumentNullException.ThrowIfNull(card); | ||
ArgumentNullException.ThrowIfNull(unhandledElements); | ||
ArgumentNullException.ThrowIfNull(errors); | ||
|
||
Card = card; | ||
UnhandledElements = unhandledElements; | ||
Errors = errors; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace IdParser.Core; | ||
|
||
/// <summary> | ||
/// Details about failure to parse or extract a meaningful value from an element's raw value obtained from | ||
/// the scanned ID text. | ||
/// </summary> | ||
/// <remarks> | ||
/// NOTE: Name ParseError instead of Error because otherwise the compiler complains: CA1716: Rename type | ||
/// Error so that it no longer conflicts with the reserved language keyword 'Error'. Using a reserved keyword | ||
/// as the name of a type makes it harder for consumers in other languages to use the type. | ||
/// </remarks> | ||
/// <param name="Message">A message describing the error that occurred.</param> | ||
/// <param name="ElementId">If element-specific, the 3-character element ID; otherwise, null.</param> | ||
/// <param name="RawValue">If element-specific, the element's raw value from the scanned ID text; otherwise, null.</param> | ||
public record ParseError(string Message, string? ElementId, string? RawValue); |
Oops, something went wrong.