Giter Site home page Giter Site logo

gs1parser's Introduction

Gs1Parser

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

Installation

The library is available via NuGet packages:

NuGet Description Version
SimpleSoft.Gs1Parser parser implementation for standard GS1 codes NuGet

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.

var gs1Parser = new Gs1Parser(new Gs1ParserOptions
{
  Separator = ';'
});

var gs1 = gs1Parser.Parse("10AB111;17260630");

Assert.Equal("AB111", gs1[Gs1ApplicationIdentifierType.Batch].DataContent); // gs1["10"].DataContent
Assert.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 = ';';

var gs1 = 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 equivalent
new Gs1Parser();
new Gs1Parser(Gs1ParserOptions.Default);

gs1parser's People

Contributors

gravity00 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

ykarpeev

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.