Example #1
0
        /// <summary>
        /// Declares an Event on the state machine with the specified data type, and allows the correlation of the event
        /// to be configured.
        /// </summary>
        /// <typeparam name="T">The event data type</typeparam>
        /// <param name="name">The event name (must be unique)</param>
        /// <param name="configure">Configuration callback method</param>
        protected Event <T> Event <T>(string name, Action <IEventCorrelationConfigurator <TInstance, T> > configure)
            where T : class
        {
            Event <T> @event = Event <T>(name);

            _eventCorrelations.TryGetValue(@event, out var existingCorrelation);

            var configurator = new MassTransitEventCorrelationConfigurator <TInstance, T>(this, @event, existingCorrelation);

            configure?.Invoke(configurator);

            _eventCorrelations[@event] = configurator.Build();

            return(@event);
        }
Example #2
0
        /// <summary>
        /// Declares an Event on the state machine with the specified data type, and allows the correlation of the event
        /// to be configured.
        /// </summary>
        /// <typeparam name="T">The event data type</typeparam>
        /// <param name="propertyExpression">The event property</param>
        /// <param name="configureEventCorrelation">Configuration callback for the event</param>
        protected void Event <T>(Expression <Func <Event <T> > > propertyExpression, Action <IEventCorrelationConfigurator <TInstance, T> > configureEventCorrelation)
            where T : class
        {
            base.Event(propertyExpression);

            var propertyInfo = propertyExpression.GetPropertyInfo();

            var @event = (Event <T>)propertyInfo.GetValue(this);

            _eventCorrelations.TryGetValue(@event, out var existingCorrelation);

            var configurator = new MassTransitEventCorrelationConfigurator <TInstance, T>(this, @event, existingCorrelation);

            configureEventCorrelation(configurator);

            _eventCorrelations[@event] = configurator.Build();
        }