コード例 #1
0
        // ReSharper disable UnusedMember.Local
        internal void ServiceCommandMethodGeneric <TCommand>(
            MethodInfo concreteMethodInfo,
            CommandOperationAttribute commandAttribute)
        // ReSharper restore UnusedMember.Local
        {
            var commandEndpointDetails = _endpointDetailsProvider
                                         .GetEndpointDetails(commandAttribute.CommandEndpointKey);
            var execute =
                (Func <TCommand, IObservable <Unit> >)Delegate.CreateDelegate(
                    typeof(Func <TCommand, IObservable <Unit> >),
                    this, concreteMethodInfo, true);

            var subscription =
                _commandListener
                .GetCommandStream <TCommand>(commandEndpointDetails)
                .Subscribe(command =>
            {
                RequestContext.Current = new RequestContext(command.SenderSessionId);
                try
                {
                    execute(command.Command);
                }
                catch (Exception)
                {
                    throw new NotImplementedException();
                }
                finally
                {
                    RequestContext.Current = null;
                }
            });

            _subscriptions.Add(subscription);
        }