public DelegateRecipientInvoker( DelegateRecipientDescriptor descriptor, Func <object, CancellationToken, object?> @delegate) { _descriptor = descriptor; _delegate = @delegate; }
public static DelegateRecipient Create <TRequest, TResponse>( Func <TRequest, CancellationToken, TResponse> @delegate, string?name) { if (@delegate is null) { throw new ArgumentNullException(nameof(@delegate)); } object?delegateInvoker(object request, CancellationToken cancellationToken) { var typedRequest = (TRequest)request; TResponse response = @delegate(typedRequest, cancellationToken); return(response); } var acceptsCancellationToken = true; var descriptor = new DelegateRecipientDescriptor(typeof(TRequest), typeof(TResponse), acceptsCancellationToken); var invoker = new DelegateRecipientInvoker(descriptor, delegateInvoker); return(new DelegateRecipient( descriptor.RequestType, descriptor.ResponseType, descriptor, invoker, name, acceptsCancellationToken)); }
public DelegateRecipientInvoker( DelegateRecipientDescriptor descriptor, Func <object, object?> @delegate) { _descriptor = descriptor; _delegate = (request, cancellationToken) => @delegate(request); }
public void Can_be_cloned() { var descriptor = new DelegateRecipientDescriptor(typeof(int), typeof(string), false);