Skip to content

Repository files navigation

Gs1Parser

Lightweight parser for GS1 strings to be used in .NET applications.

Installation

The library is available via NuGet packages:

NuGetDescriptionVersion
SimpleSoft.Gs1Parserparser implementation for standard GS1 codesNuGet

Package Manager

Install-Package SimpleSoft.Gs1Parser

.NET CLI

dotnet add package SimpleSoft.Gs1Parser

Compatibility

This library is compatible with the following frameworks:

  • SimpleSoft.Gs1Parser
    • .NET 5.0+;
    • .NET Framework 4.5+;
    • .NET Standard 1.0+;

Usage

Parsing of GS1 strings are made via Gs1Parser instances, that can be configured via Gs1ParserOptions class.

vargs1Parser=newGs1Parser(newGs1ParserOptions{Separator=';'});vargs1=gs1Parser.Parse("10AB111;17260630");Assert.Equal("AB111",gs1[Gs1ApplicationIdentifierType.Batch].DataContent);// gs1["10"].DataContentAssert.Equal("260630",gs1[Gs1ApplicationIdentifierType.UseBy].DataContent);// gs1["17"].DataContent

The library also provides both a default options and parser that can be used instead of initializing your own instances (the parser implementation is thread safe, you can use it as a singleton across your application):

Gs1ParserOptions.Default.Separator=';';vargs1=Gs1Parser.Default.Parse("10AB111;17260630");Assert.Equal("AB111",gs1[Gs1ApplicationIdentifierType.Batch].DataContent);Assert.Equal("260630",gs1[Gs1ApplicationIdentifierType.UseBy].DataContent);

As a note, if you initialize a Gs1Parser instance without passing an options, it will use the default one.

// both lines are equivalentnewGs1Parser();newGs1Parser(Gs1ParserOptions.Default);

About

Lightweight GS1 parser for .NET applications

Topics

Resources

Stars

9 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages