src/Impl/QueryDispatcher.cs
/// <summary>
/// Dispatches query to its handler.
/// </summary>
/// <typeparam name="TResult">Type of result.</typeparam>
/// <param name="query">Query object.</param>
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
/// <returns>A task that represents the asynchronous dispatch operation.</returns>
Dispatches query to its handler.
Dispatches query to its handler .
public Task<TResult> DispatchAsync<TResult>(IQuery<TResult> query, CancellationToken cancellationToken)
		{
			if (query == null) throw new ArgumentNullException(nameof(query));
			Type queryType = query.GetType();
			object handler = ResolveHandler(queryType, typeof(TResult));
            if (HandleMethods.TryGetValue(handler.GetType(), out var method) == false)
            {
				method = handler.GetType().GetRuntimeMethod("HandleAsync", new[] { queryType, cancellationToken.GetType() });
                HandleMethods.Add(handler.GetType(), method);
            }
			return (Task<TResult>) method.Invoke(handler, new object[] {query, cancellationToken});
		}
public Task < TResult > DispatchAsync < TResult > ( IQuery < TResult > query , CancellationToken cancellationToken ) { if ( query == null ) throw new ArgumentNullException ( nameof ( query ) ) ; Type queryType = query . GetType ( ) ; object handler = ResolveHandler ( queryType , typeof ( TResult ) ) ; if ( HandleMethods . TryGetValue ( handler . GetType ( ) , out var method ) == false ) { method = handler . GetType ( ) . GetRuntimeMethod ( " " , new [ ] { queryType , cancellationToken . GetType ( ) } ) ; HandleMethods . Add ( handler . GetType ( ) , method ) ; } return ( Task < TResult > ) method . Invoke ( handler , new object [ ] { query , cancellationToken } ) ; }
Dispatches query to its handler.
Dispatches query to its handler .
A task that represents the asynchronous dispatch operation.
A task that represents the asynchronous dispatch operation .
query
IQuery<TResult>
None
cancellationToken
CancellationToken
The token to monitor for cancellation requests.
The token to monitor for cancellation requests .
typeparam
Type of result.
Type of result .