Class WildcardExpressionBarCodeMatcher
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
wildcardExpressionWildcardExpressionThe 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
wildcardExpressionis null.
Properties
NumberIds
Gets the list of number identifiers that this bar code matcher can capture.
public override IReadOnlyList<string> NumberIds { get; }
Property Value
WildcardExpression
Gets the wildcard expression to use to match bar code content.
public WildcardExpression WildcardExpression { get; }
Property Value
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
barCodestringThe bar code content.
numbersIReadOnlyDictionary<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
Remarks
See the remarks for WildcardExpressionBarCodeMatcher for details about the logic used to produce the captured numbers.
Exceptions
- ArgumentNullException
barCodeis null.