Table of Contents

Class TypeParser

Namespace
Rinku.Mapping
Assembly
Rinku.dll

Builds the parser that reads a result into a given T. Cached parsers decide which schemas they can accept. When none can, the makers in TypeParserMakers are tried in order and the first to claim T builds one. Add a maker to that list to register a custom result type.

public static class TypeParser
Inheritance
TypeParser
Inherited Members

Fields

TypeParserMakers

The makers tried in order to build a parser for a T, the built-in result shapes among them. Insert your own ahead of the defaults to add a shape (see the parsers guide).

public static readonly TypeParserMakerCollection TypeParserMakers

Field Value

TypeParserMakerCollection

Properties

DefaultTypeParserMaker

The fallback maker used when no registered shape maker claims a type.

public static ITypeParserMaker DefaultTypeParserMaker { get; set; }

Property Value

ITypeParserMaker

Methods

GetDefaultNullColHandler(Type)

The root nullability implied by type itself.

public static INullColHandler GetDefaultNullColHandler(Type type)

Parameters

type Type

Returns

INullColHandler

GetDefaultNullColHandler<T>()

The root nullability implied by T itself.

public static INullColHandler GetDefaultNullColHandler<T>()

Returns

INullColHandler

Type Parameters

T

GetTypeParser(Type, ColumnInfo[], INullColHandler?)

Gets the cached parser for a runtime result type and schema.

public static ITypeParser GetTypeParser(Type type, ColumnInfo[] cols, INullColHandler? nullColHandler = null)

Parameters

type Type
cols ColumnInfo[]
nullColHandler INullColHandler

Returns

ITypeParser

GetTypeParser<T>(ColumnInfo[], INullColHandler?)

Gets a parser for T that accepts the supplied columns. Reuse the returned parser or a QueryCommand instead of calling this for every execution.

public static ITypeParser<T> GetTypeParser<T>(ColumnInfo[] cols, INullColHandler? nullColHandler = null)

Parameters

cols ColumnInfo[]

The columns the result carries.

nullColHandler INullColHandler

A custom root null rule. When omitted or equal to GetDefaultNullColHandler(Type), the type's own nullability applies

Returns

ITypeParser<T>

Type Parameters

T

GetTypeParser<T>(Delegate, out ColumnInfo[], INullColHandler?)

The parser for T over the columns derived from a factory delegate's parameters.

public static ITypeParser<T> GetTypeParser<T>(Delegate factory, out ColumnInfo[] cols, INullColHandler? nullColHandler = null)

Parameters

factory Delegate
cols ColumnInfo[]
nullColHandler INullColHandler

Returns

ITypeParser<T>

Type Parameters

T

GetTypeParser<T>(ConstructorInfo, out ColumnInfo[], INullColHandler?)

The parser for T over the columns derived from a constructor's parameters.

public static ITypeParser<T> GetTypeParser<T>(ConstructorInfo ctor, out ColumnInfo[] cols, INullColHandler? nullColHandler = null)

Parameters

ctor ConstructorInfo
cols ColumnInfo[]
nullColHandler INullColHandler

Returns

ITypeParser<T>

Type Parameters

T

GetTypeParser<T>(MethodBase, out ColumnInfo[], INullColHandler?)

The parser for T over the columns derived from a method's parameters.

public static ITypeParser<T> GetTypeParser<T>(MethodBase method, out ColumnInfo[] cols, INullColHandler? nullColHandler = null)

Parameters

method MethodBase
cols ColumnInfo[]
nullColHandler INullColHandler

Returns

ITypeParser<T>

Type Parameters

T

GetTypeParser<T>(Type, out ColumnInfo[], INullColHandler?)

The parser for T over the columns derived from type.

public static ITypeParser<T> GetTypeParser<T>(Type type, out ColumnInfo[] cols, INullColHandler? nullColHandler = null)

Parameters

type Type
cols ColumnInfo[]
nullColHandler INullColHandler

Returns

ITypeParser<T>

Type Parameters

T

GetTypeParser<TSchema, T>(out ColumnInfo[], INullColHandler?)

The parser for T over the columns of TSchema, taken from its shape rather than a result.

public static ITypeParser<T> GetTypeParser<TSchema, T>(out ColumnInfo[] cols, INullColHandler? nullColHandler = null)

Parameters

cols ColumnInfo[]
nullColHandler INullColHandler

Returns

ITypeParser<T>

Type Parameters

TSchema
T

Invalidate(ColumnInfo[], ParserInvalidationMode)

Removes every global parser that accepts schema and applies mode to caches retaining those exact parser instances.

public static int Invalidate(ColumnInfo[] schema, ParserInvalidationMode mode)

Parameters

schema ColumnInfo[]
mode ParserInvalidationMode

Returns

int

The number of distinct parsers removed.

Invalidate(ITypeParser, ParserInvalidationMode)

Removes one exact parser instance from the global cache.

public static bool Invalidate(ITypeParser parser, ParserInvalidationMode mode)

Parameters

parser ITypeParser
mode ParserInvalidationMode

Returns

bool

true when the parser was globally cached.

InvalidateAll(ParserInvalidationMode)

Removes every parser from the global cache.

public static int InvalidateAll(ParserInvalidationMode mode)

Parameters

mode ParserInvalidationMode

Returns

int

The number of distinct parsers removed.

Release(ITypeParser)

Releases an owner's reference to parser and disposes it only when neither the global cache nor another subscribed cache reports that it still retains the same instance.

public static bool Release(ITypeParser parser)

Parameters

parser ITypeParser

Returns

bool

true when the parser was disposed. Otherwise false.

TryInstallDefaults(ITypeParserMaker, params ITypeParserMaker[])

Installs the initial fallback and parser makers. Call this once during startup when replacing all supplied defaults.

public static bool TryInstallDefaults(ITypeParserMaker fallback, params ITypeParserMaker[] makers)

Parameters

fallback ITypeParserMaker
makers ITypeParserMaker[]

Returns

bool

Events

ParserDisposing

Raised after a parser leaves the global cache and before it is disposed. A cache retaining the exact parser either cancels CheckUsage or releases its reference for InvalidateReferences.

public static event EventHandler<ParserDisposingEventArgs>? ParserDisposing

Event Type

EventHandler<ParserDisposingEventArgs>