Interface ITypeParserMaker
Creates parsers for custom result types. Add a maker to TypeParserMakers before the default makers.
public interface ITypeParserMaker
- Extension Methods
Methods
CanHandle<T>()
Whether this maker claims T.
bool CanHandle<T>()
Returns
Type Parameters
T
TryColdStart(Type, DbCommand, ICacheGivingParser, bool, out object?)
Tries to run T before the returned columns are known.
Return false when a parser must be created after the reader opens.
bool TryColdStart(Type type, DbCommand cmd, ICacheGivingParser cache, bool disposeCommand, out object? result)
Parameters
typeTypecmdDbCommandThe command to run, not yet run.
cacheICacheGivingParserTurns the reader's columns into the parser for
T.disposeCommandboolWhether the command is this run's to dispose.
resultobjectThe result, when this maker took the run.
Returns
Remarks
Use this for a deferred result that must open the reader while it is consumed. Return false for buffered results or when the columns must be known first.
TryColdStart(Type, IDbCommand, ICacheGivingParser, bool, out object?)
Tries to run T before the returned columns are known.
Return false when a parser must be created after the reader opens.
bool TryColdStart(Type type, IDbCommand cmd, ICacheGivingParser cache, bool disposeCommand, out object? result)
Parameters
typeTypecmdIDbCommandThe command to run, not yet run.
cacheICacheGivingParserTurns the reader's columns into the parser for
T.disposeCommandboolWhether the command is this run's to dispose.
resultobjectThe result, when this maker took the run.
Returns
Remarks
Use this for a deferred result that must open the reader while it is consumed. Return false for buffered results or when the columns must be known first.
TryColdStartAsync(Type, DbCommand, ICacheGivingParser, bool, CancellationToken, out Task<object?>?)
Attempts to produce a deferred object result for a runtime result type.
bool TryColdStartAsync(Type type, DbCommand cmd, ICacheGivingParser cache, bool disposeCommand, CancellationToken ct, out Task<object?>? result)
Parameters
typeTypecmdDbCommandcacheICacheGivingParserdisposeCommandboolctCancellationTokenresultTask<object>
Returns
TryColdStartAsync(Type, IDbCommand, ICacheGivingParser, bool, CancellationToken, out Task<object?>?)
Attempts to produce a deferred object result for a runtime result type.
bool TryColdStartAsync(Type type, IDbCommand cmd, ICacheGivingParser cache, bool disposeCommand, CancellationToken ct, out Task<object?>? result)
Parameters
typeTypecmdIDbCommandcacheICacheGivingParserdisposeCommandboolctCancellationTokenresultTask<object>
Returns
TryColdStartAsync<T>(DbCommand, ICacheGivingParser<T>, bool, CancellationToken, out Task<T>)
The asynchronous form of TryColdStart<T>(DbCommand, ICacheGivingParser<T>, bool, out T).
bool TryColdStartAsync<T>(DbCommand cmd, ICacheGivingParser<T> cache, bool disposeCommand, CancellationToken ct, out Task<T> result)
Parameters
cmdDbCommandThe command to run, not yet run.
cacheICacheGivingParser<T>Turns the reader's columns into the parser for
T.disposeCommandboolWhether the command is this run's to dispose.
ctCancellationTokenThe token the caller is running under.
resultTask<T>The result, when this maker took the run.
Returns
Type Parameters
T
Remarks
Return a completed task when no asynchronous work is needed. The synchronous and asynchronous methods may accept different result types.
TryColdStartAsync<T>(IDbCommand, ICacheGivingParser<T>, bool, CancellationToken, out Task<T>)
The asynchronous form of TryColdStart<T>(DbCommand, ICacheGivingParser<T>, bool, out T).
bool TryColdStartAsync<T>(IDbCommand cmd, ICacheGivingParser<T> cache, bool disposeCommand, CancellationToken ct, out Task<T> result)
Parameters
cmdIDbCommandThe command to run, not yet run.
cacheICacheGivingParser<T>Turns the reader's columns into the parser for
T.disposeCommandboolWhether the command is this run's to dispose.
ctCancellationTokenThe token the caller is running under.
resultTask<T>The result, when this maker took the run.
Returns
Type Parameters
T
Remarks
Return a completed task when no asynchronous work is needed. The synchronous and asynchronous methods may accept different result types.
TryColdStart<T>(DbCommand, ICacheGivingParser<T>, bool, out T)
Tries to run T before the returned columns are known.
Return false when a parser must be created after the reader opens.
bool TryColdStart<T>(DbCommand cmd, ICacheGivingParser<T> cache, bool disposeCommand, out T result)
Parameters
cmdDbCommandThe command to run, not yet run.
cacheICacheGivingParser<T>Turns the reader's columns into the parser for
T.disposeCommandboolWhether the command is this run's to dispose.
resultTThe result, when this maker took the run.
Returns
Type Parameters
T
Remarks
Use this for a deferred result that must open the reader while it is consumed. Return false for buffered results or when the columns must be known first.
TryColdStart<T>(IDbCommand, ICacheGivingParser<T>, bool, out T)
Tries to run T before the returned columns are known.
Return false when a parser must be created after the reader opens.
bool TryColdStart<T>(IDbCommand cmd, ICacheGivingParser<T> cache, bool disposeCommand, out T result)
Parameters
cmdIDbCommandThe command to run, not yet run.
cacheICacheGivingParser<T>Turns the reader's columns into the parser for
T.disposeCommandboolWhether the command is this run's to dispose.
resultTThe result, when this maker took the run.
Returns
Type Parameters
T
Remarks
Use this for a deferred result that must open the reader while it is consumed. Return false for buffered results or when the columns must be known first.
TryMakeParser<T>(INullColHandler, ColumnInfo[], out ITypeParser<T>)
Builds the parser for T over the given columns, or returns false
to decline.
bool TryMakeParser<T>(INullColHandler nullColHandler, ColumnInfo[] cols, out ITypeParser<T> parser)
Parameters
nullColHandlerINullColHandlercolsColumnInfo[]parserITypeParser<T>
Returns
Type Parameters
T
Remarks
nullColHandler is the requested root nullability. It is
GetDefaultNullColHandler<T>() (the type's own nullability) unless a caller
replaced it. The method must accept any INullColHandler.