Table of Contents

Class ResolverSource

Namespace
Invex.Rez.Implementation
Assembly
Invex.Rez.dll

An immutable IResolverSource backed by fixed maps of variables and functions supplied at construction time.

[PublicAPI]
public sealed class ResolverSource : IResolverSource
Inheritance
object
ResolverSource
Implements

Remarks

Use this when the set of variables and functions is known up front. For a mutable source, use ResolverStore instead.

Constructors

ResolverSource(Dictionary<string, Func<FunctionCall, string>>)

Creates a new ResolverSource with the given functions and no variables.

public ResolverSource(Dictionary<string, Func<FunctionCall, string>> functions)

Parameters

functions Dictionary<string, Func<FunctionCall, string>>

A map of function names to their implementations.

Exceptions

ArgumentNullException

Thrown if functions is null.

ResolverSource(Dictionary<string, string>)

Creates a new ResolverSource with the given variables and no functions.

public ResolverSource(Dictionary<string, string> variables)

Parameters

variables Dictionary<string, string>

A map of variable names to their values.

Exceptions

ArgumentNullException

Thrown if variables is null.

ResolverSource(Dictionary<string, string>, Dictionary<string, Func<FunctionCall, string>>)

Creates a new ResolverSource with the given variables and functions.

public ResolverSource(Dictionary<string, string> variables, Dictionary<string, Func<FunctionCall, string>> functions)

Parameters

variables Dictionary<string, string>

A map of variable names to their values.

functions Dictionary<string, Func<FunctionCall, string>>

A map of function names to their implementations.

Exceptions

ArgumentNullException

Thrown if variables or functions is null.

ResolverSource(IEnumerable<KeyValuePair<string, Func<FunctionCall, string>>>)

Creates a new ResolverSource with the given functions and no variables.

public ResolverSource(IEnumerable<KeyValuePair<string, Func<FunctionCall, string>>> functions)

Parameters

functions IEnumerable<KeyValuePair<string, Func<FunctionCall, string>>>

A sequence of function names and their implementations.

Exceptions

ArgumentException

Thrown if the sequence contains duplicate names.

ResolverSource(IEnumerable<KeyValuePair<string, string>>)

Creates a new ResolverSource with the given variables and no functions.

public ResolverSource(IEnumerable<KeyValuePair<string, string>> variables)

Parameters

variables IEnumerable<KeyValuePair<string, string>>

A sequence of variable names and their values.

Exceptions

ArgumentException

Thrown if the sequence contains duplicate names.

ResolverSource(IEnumerable<KeyValuePair<string, string>>, IEnumerable<KeyValuePair<string, Func<FunctionCall, string>>>)

Creates a new ResolverSource with the given variables and functions.

public ResolverSource(IEnumerable<KeyValuePair<string, string>> variables, IEnumerable<KeyValuePair<string, Func<FunctionCall, string>>> functions)

Parameters

variables IEnumerable<KeyValuePair<string, string>>

A sequence of variable names and their values.

functions IEnumerable<KeyValuePair<string, Func<FunctionCall, string>>>

A sequence of function names and their implementations.

Exceptions

ArgumentException

Thrown if either sequence contains duplicate names.

Methods

ResolveFunction(string)

Resolves a function with the given name.

public Func<FunctionCall, string>? ResolveFunction(string name)

Parameters

name string

The name of the function to resolve.

Returns

Func<FunctionCall, string>

A delegate that produces the function's result from a FunctionCall, or null if this source cannot resolve the function.
Returning null allows the next source registered with the IResolver to be queried.

Remarks

The braces, parentheses, and arguments that denote a function in a template are not included in the name - for the template {repeat(abc,3)}, the name is "repeat".

ResolveVariable(string)

Resolves a variable with the given name.

public string? ResolveVariable(string name)

Parameters

name string

The name of the variable to resolve.

Returns

string

The value of the variable, or null if this source cannot resolve the variable.
Returning null allows the next source registered with the IResolver to be queried.

Remarks

The braces that denote a variable in a template are not included in the name - for the template {color}, the name is "color".