Table of Contents

Class WildcardExpressionBarCodeMatcher

Namespace
Acuit.Pinpoint.Common.BarCodes
Assembly
Acuit.Pinpoint.Common.dll

A bar code matcher that uses a wildcard expression to match and extract numbers from bar code content.

public class WildcardExpressionBarCodeMatcher : BarCodeMatcher
Inheritance
WildcardExpressionBarCodeMatcher
Inherited Members

Remarks

A WildcardExpression is used to match bar code content by testing to see if the content matches the wildcard expression.

Numbers are extracted from the bar code content using named captures specified in the wildcard expression, where the name is used as the number identifier. A named capture for the same name can be specified multiple times in the wildcard expression; in that case, the first match will be used to produce the resulting number. If the bar code content matched the wildcard expression, but one or more named captures in the expression did not capture a value, then they will produce empty strings for the number balues. For example, if the format is S{serial}|M{model} and the bar code is S1234, the numbers returned will be "1234" for "serial", and "" for "model".

Constructors

WildcardExpressionBarCodeMatcher(WildcardExpression)

Initializes a new instance of the WildcardExpressionBarCodeMatcher class.

public WildcardExpressionBarCodeMatcher(WildcardExpression wildcardExpression)

Parameters

wildcardExpression WildcardExpression

The wildcard expression to use to match bar code content, with named captures used to extract numbers. This should typically be created with the Singleline option specified. See the remarks for WildcardExpressionBarCodeMatcher for details about how this wildcard expression will be used to capture numbers.

Exceptions

ArgumentNullException

wildcardExpression is null.

Properties

NumberIds

Gets the list of number identifiers that this bar code matcher can capture.

public override IReadOnlyList<string> NumberIds { get; }

Property Value

IReadOnlyList<string>

WildcardExpression

Gets the wildcard expression to use to match bar code content.

public WildcardExpression WildcardExpression { get; }

Property Value

WildcardExpression

Methods

TryMatchBarCode(string, out IReadOnlyDictionary<string, string>?)

Tries to match a bar code.

public override bool TryMatchBarCode(string barCode, out IReadOnlyDictionary<string, string>? numbers)

Parameters

barCode string

The bar code content.

numbers IReadOnlyDictionary<string, string>

On return, if the bar code content matched, the numbers found in the bar code as a dictionary keyed by their number identifiers (case-sensitive); otherwise, null.

Returns

bool

true if the bar code matches; othersise, false.

Remarks

See the remarks for WildcardExpressionBarCodeMatcher for details about the logic used to produce the captured numbers.

Exceptions

ArgumentNullException

barCode is null.