Class TypeParser
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
Properties
DefaultTypeParserMaker
The fallback maker used when no registered shape maker claims a type.
public static ITypeParserMaker DefaultTypeParserMaker { get; set; }
Property Value
Methods
GetDefaultNullColHandler(Type)
The root nullability implied by type itself.
public static INullColHandler GetDefaultNullColHandler(Type type)
Parameters
typeType
Returns
GetDefaultNullColHandler<T>()
The root nullability implied by T itself.
public static INullColHandler GetDefaultNullColHandler<T>()
Returns
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
typeTypecolsColumnInfo[]nullColHandlerINullColHandler
Returns
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
colsColumnInfo[]The columns the result carries.
nullColHandlerINullColHandlerA 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
factoryDelegatecolsColumnInfo[]nullColHandlerINullColHandler
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
ctorConstructorInfocolsColumnInfo[]nullColHandlerINullColHandler
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
methodMethodBasecolsColumnInfo[]nullColHandlerINullColHandler
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
typeTypecolsColumnInfo[]nullColHandlerINullColHandler
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
colsColumnInfo[]nullColHandlerINullColHandler
Returns
- ITypeParser<T>
Type Parameters
TSchemaT
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
schemaColumnInfo[]modeParserInvalidationMode
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
parserITypeParsermodeParserInvalidationMode
Returns
InvalidateAll(ParserInvalidationMode)
Removes every parser from the global cache.
public static int InvalidateAll(ParserInvalidationMode mode)
Parameters
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
parserITypeParser
Returns
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
fallbackITypeParserMakermakersITypeParserMaker[]
Returns
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