private void Add(Type asyncHandlerType, Type messageType, Func <object, object, Task> handleMethod) { var typeHandle = asyncHandlerType.TypeHandle; var asyncMessageDelegate = new AsyncMessageDelegate(messageType, handleMethod); IList <AsyncMessageDelegate> methodList; if (this.handlerCache.TryGetValue(typeHandle, out methodList)) { if (methodList.Any(x => x.CanHandle(messageType))) { return; } methodList.Add(asyncMessageDelegate); } else { this.handlerCache[typeHandle] = new List <AsyncMessageDelegate> { asyncMessageDelegate }; } }
public AsyncMessageDelegateTest() { this.testee = new AsyncMessageDelegate( typeof(ValueCommand), (handler, message) => (handler as IHandleAsync <ValueCommand>).HandleAsync(new ValueCommand(11))); }