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(Type, Delegate, INullColHandler?)
Gets a parser for a runtime result type over the columns derived from schemaFactory.
public static ITypeParser GetTypeParser(Type resultType, Delegate schemaFactory, INullColHandler? nullColHandler = null)
Parameters
resultTypeTypeschemaFactoryDelegatenullColHandlerINullColHandler
Returns
GetTypeParser(Type, ConstructorInfo, INullColHandler?)
Gets a parser for a runtime result type over the columns derived from schemaConstructor.
public static ITypeParser GetTypeParser(Type resultType, ConstructorInfo schemaConstructor, INullColHandler? nullColHandler = null)
Parameters
resultTypeTypeschemaConstructorConstructorInfonullColHandlerINullColHandler
Returns
GetTypeParser(Type, MemberInfo, INullColHandler?)
Gets a parser for a runtime result type over a reflected type, method, or constructor.
public static ITypeParser GetTypeParser(Type resultType, MemberInfo schemaMember, INullColHandler? nullColHandler = null)
Parameters
resultTypeTypeschemaMemberMemberInfonullColHandlerINullColHandler
Returns
GetTypeParser(Type, MethodBase, INullColHandler?)
Gets a parser for a runtime result type over the columns derived from schemaMethod.
public static ITypeParser GetTypeParser(Type resultType, MethodBase schemaMethod, INullColHandler? nullColHandler = null)
Parameters
resultTypeTypeschemaMethodMethodBasenullColHandlerINullColHandler
Returns
GetTypeParser(Type, Type, INullColHandler?)
Gets a parser for a runtime result type over the columns derived from schemaType.
public static ITypeParser GetTypeParser(Type resultType, Type schemaType, INullColHandler? nullColHandler = null)
Parameters
resultTypeTypeschemaTypeTypenullColHandlerINullColHandler
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, INullColHandler?)
The parser for T over the columns derived from schemaFactory.
public static ITypeParser<T> GetTypeParser<T>(Delegate schemaFactory, INullColHandler? nullColHandler = null)
Parameters
schemaFactoryDelegatenullColHandlerINullColHandler
Returns
- ITypeParser<T>
Type Parameters
T
GetTypeParser<T>(ConstructorInfo, INullColHandler?)
The parser for T over the columns derived from schemaConstructor.
public static ITypeParser<T> GetTypeParser<T>(ConstructorInfo schemaConstructor, INullColHandler? nullColHandler = null)
Parameters
schemaConstructorConstructorInfonullColHandlerINullColHandler
Returns
- ITypeParser<T>
Type Parameters
T
GetTypeParser<T>(MemberInfo, INullColHandler?)
The parser for T over a reflected type, method, or constructor.
public static ITypeParser<T> GetTypeParser<T>(MemberInfo schemaMember, INullColHandler? nullColHandler = null)
Parameters
schemaMemberMemberInfonullColHandlerINullColHandler
Returns
- ITypeParser<T>
Type Parameters
T
GetTypeParser<T>(MethodBase, INullColHandler?)
The parser for T over the columns derived from schemaMethod.
public static ITypeParser<T> GetTypeParser<T>(MethodBase schemaMethod, INullColHandler? nullColHandler = null)
Parameters
schemaMethodMethodBasenullColHandlerINullColHandler
Returns
- ITypeParser<T>
Type Parameters
T
GetTypeParser<T>(Type, INullColHandler?)
The parser for T over the columns derived from schemaType.
public static ITypeParser<T> GetTypeParser<T>(Type schemaType, INullColHandler? nullColHandler = null)
Parameters
schemaTypeTypenullColHandlerINullColHandler
Returns
- ITypeParser<T>
Type Parameters
T
GetTypeParser<TSchema, T>(INullColHandler?)
The parser for T over the columns of TSchema.
public static ITypeParser<T> GetTypeParser<TSchema, T>(INullColHandler? nullColHandler = null)
Parameters
nullColHandlerINullColHandler
Returns
- ITypeParser<T>
Type Parameters
TSchemaT
Invalidate(Func<ITypeParser, bool>, ParserInvalidationMode)
Removes every global parser for which predicate returns true.
public static int Invalidate(Func<ITypeParser, bool> predicate, ParserInvalidationMode mode)
Parameters
predicateFunc<ITypeParser, bool>Selects the globally cached parser instances to remove.
modeParserInvalidationModeControls whether caches retaining a selected parser must release it or may keep it alive.
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