public TService Resolve <TService>() { try { return(Container.Resolve <TService>()); } catch (TargetInvocationException e) { throw InvocationUtil.Inner(e); } }
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(); } } }