示例#1
0
 public TService Resolve <TService>()
 {
     try
     {
         return(Container.Resolve <TService>());
     }
     catch (TargetInvocationException e)
     {
         throw InvocationUtil.Inner(e);
     }
 }
示例#2
0
 public void Dispatch(Type consumerType, ImmutableEnvelope envelop, ImmutableMessage message)
 {
     using (var inner = _envelopeScope.BeginLifetimeScope(DispatchLifetimeScopeTags.MessageItemScopeTag))
     {
         var instance = inner.Resolve(consumerType);
         var consume  = _hint(consumerType, message.MappedType);
         try
         {
             _context.SetContext(envelop, message);
             consume.Invoke(instance, new[] { message.Content });
         }
         catch (TargetInvocationException e)
         {
             throw InvocationUtil.Inner(e);
         }
         finally
         {
             _context.ClearContext();
         }
     }
 }