Ejemplo n.º 1
0
        public Task <ApiResponse <Unit> > Execute <TCommand>(
            CommandExecutionContext <TConnection, TCommand> context
            )
            where TCommand : ICommand
        {
            ExecuteCache <TCommand> .EnsureInitialized(_steps);

            return(ExecuteCache <TCommand> .Pipeline(context));
        }
        public override OrganizationResponse Execute(OrganizationRequest request)
        {
            OrganizationResponse response;

            if (RedirectExecuteRequestsToOrganizationServiceRequest)
            {
                response = CallOrganizationServiceRequestForExecuteRequest(request);

                if (response != null)
                {
                    return(response);
                }
            }

            if (ExecuteFunc != null)
            {
                response = ExecuteFunc(Service, request);
            }
            else if (ExecuteFuncs != null)
            {
                if (ExecuteCache == null)
                {
                    ExecuteCache = Service;
                    foreach (var execute in ExecuteFuncs)
                    {
                        ExecuteCache = new FakeIOrganizationService(ExecuteCache)
                        {
                            ExecuteFunc = execute
                        };
                    }
                }
                response = ExecuteCache.Execute(request);
            }
            else
            {
                response = ExecutionTracingEnabled ? Timer.Time(ExecuteInternal, request, "Execute {0}: {1}", request.RequestName) : Service.Execute(request);
            }
            return(response);
        }