예제 #1
0
 public IHandleMessagesWithLocksBuilder HandleRequestAsync <TRequest, TReply>(Func <IOperationContext, TRequest, Task <TReply> > handler, LockType lockType = LockType.Write)
     where TRequest : Message
     where TReply : Message
 {
     _handlerByType[typeof(TRequest)] = new LockedOperationDesc(async(operation) => await handler(operation, operation.Message as TRequest), lockType);
     return(this);
 }
예제 #2
0
 public IHandleMessagesWithLocksBuilder HandleMessage <TRequest>(Action <IOperationContext, TRequest> handler, LockType lockType = LockType.Write)
     where TRequest : Message
 {
     _handlerByType[typeof(TRequest)] = new LockedOperationDesc((operation) =>
     {
         handler(operation, operation.Message as TRequest);
         return(Task.FromResult <Message>(null));
     }, lockType);
     return(this);
 }
예제 #3
0
 public IHandleMessagesWithLocksBuilder HandleRequest <TRequest>(Func <IOperationContext, TRequest, Message> handler, LockType lockType = LockType.Write)
     where TRequest : Message
 {
     _handlerByType[typeof(TRequest)] = new LockedOperationDesc((operation) =>
     {
         var msg = handler(operation, operation.Message as TRequest);
         return(Task.FromResult(msg));
     }, lockType);
     return(this);
 }