Table of Contents

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

string

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

fieldChain string

The dot-separated chain of resource field names.

resourceType ResourceType

The parent resource type to start matching from.

options FieldChainPatternMatchOptions

Match options, defaults to None.

loggerFactory ILoggerFactory

When 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

pattern string

Returns

FieldChainPattern

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.
For example, the pattern "M?O*A" matches "children.parent.name", "parent.parent.name" and "name".

Exceptions

PatternFormatException

The pattern is invalid.

ToString()

Gets the text representation of this pattern.

public override string ToString()

Returns

string