Пример #1
0
        public ISendScopeContext <T> GetScope <T>(SendContext <T> context)
            where T : class
        {
            if (context.TryGetPayload <IKernel>(out _))
            {
                return(new ExistingSendScopeContext <T>(context));
            }

            var scope = _kernel.CreateNewMessageScope(context);

            try
            {
                var sendContext = new SendContextScope <T>(context, _kernel);

                return(new CreatedSendScopeContext <IDisposable, T>(scope, sendContext));
            }
            catch
            {
                scope?.Dispose();
                throw;
            }
        }