Example #1
0
        /// <summary>
        /// Declares a request that is sent by the state machine to a service, and the associated response, fault, and
        /// timeout handling. The property is initialized with the fully built Request. The request must be declared before
        /// it is used in the state/event declaration statements.
        /// Uses the Saga CorrelationId as the RequestId
        /// </summary>
        /// <typeparam name="TRequest">The request type</typeparam>
        /// <typeparam name="TResponse">The response type</typeparam>
        /// <param name="propertyExpression">The request property on the state machine</param>
        /// <param name="configureRequest">Allow the request settings to be specified inline</param>
        protected void Request <TRequest, TResponse>(Expression <Func <Request <TInstance, TRequest, TResponse> > > propertyExpression,
                                                     Action <IRequestConfigurator> configureRequest = default)
            where TRequest : class
            where TResponse : class
        {
            var configurator = new StateMachineRequestConfigurator <TRequest>();

            configureRequest?.Invoke(configurator);

            Request(propertyExpression, configurator.Settings);
        }
        /// <summary>
        /// Declares a request that is sent by the state machine to a service, and the associated response, fault, and
        /// timeout handling. The property is initialized with the fully built Request. The request must be declared before
        /// it is used in the state/event declaration statements.
        /// </summary>
        /// <typeparam name="TRequest">The request type</typeparam>
        /// <typeparam name="TResponse">The response type</typeparam>
        /// <param name="propertyExpression">The request property on the state machine</param>
        /// <param name="requestIdExpression">The property where the requestId is stored</param>
        /// <param name="configureRequest">Allow the request settings to be specified inline</param>
        protected void Request <TRequest, TResponse>(Expression <Func <Request <TInstance, TRequest, TResponse> > > propertyExpression,
                                                     Expression <Func <TInstance, Guid?> > requestIdExpression,
                                                     Action <RequestConfigurator <TInstance, TRequest, TResponse> > configureRequest)
            where TRequest : class
            where TResponse : class
        {
            var configurator = new StateMachineRequestConfigurator <TInstance, TRequest, TResponse>();

            configureRequest(configurator);

            Request(propertyExpression, requestIdExpression, configurator.Settings);
        }