Class FieldChainPattern
- Namespace
- JsonApiDotNetCore.QueryStrings.FieldChains
- Assembly
- JsonApiDotNetCore.dll
A pattern that can be matched against a dot-separated resource field chain.
[PublicAPI]
public sealed class FieldChainPattern
- Inheritance
-
FieldChainPattern
- Inherited Members
Methods
GetDescription()
Gets a human-readable description of this pattern.
public string GetDescription()
Returns
Match(string, ResourceType, FieldChainPatternMatchOptions, ILoggerFactory?)
Matches the specified resource field chain against this pattern.
public PatternMatchResult Match(string fieldChain, ResourceType resourceType, FieldChainPatternMatchOptions options = FieldChainPatternMatchOptions.None, ILoggerFactory? loggerFactory = null)
Parameters
fieldChainstringThe dot-separated chain of resource field names.
resourceTypeResourceTypeThe parent resource type to start matching from.
optionsFieldChainPatternMatchOptionsMatch options, defaults to None.
loggerFactoryILoggerFactoryWhen provided, logs the matching steps at Trace level.
Returns
- PatternMatchResult
The match result.
Parse(string)
Creates a pattern from the specified text that can be matched against.
public static FieldChainPattern Parse(string pattern)
Parameters
patternstring
Returns
Remarks
Patterns are similar to regular expressions, but a lot simpler. They consist of a sequence of terms. A term can be a single character or a character choice. A term is optionally followed by a quantifier.
The following characters can be used:
| M | Matches a to-many relationship. |
| O | Matches a to-one relationship. |
| R | Matches a relationship. |
| A | Matches an attribute. |
| F | Matches a field. |
A character choice contains a set of characters, surrounded by brackets. One of the choices must match. For example, "[MO]" matches a relationship, but not at attribute.
A quantifier is used to indicate how many times its term directly to the left can occur.| ? | Matches its preceding term zero or one times. |
| * | Matches its preceding term zero or more times. |
| + | Matches its preceding term one or more times. |
Exceptions
- PatternFormatException
The pattern is invalid.
ToString()
Gets the text representation of this pattern.
public override string ToString()