A spontaneous publication is used when there is no real publisher but EventBroker.Fire was called directly to fire an event.
Inheritance: Appccelerate.EventBroker.Internals.Publications.Publication
示例#1
0
        /// <summary>
        /// Fires the specified topic directly on the <see cref="IEventBroker"/> without a real publisher.
        /// This is useful when temporarily created objects need to fire events.
        /// The event is fired globally but can be matched with <see cref="Matchers.ISubscriptionMatcher"/>.
        /// </summary>
        /// <param name="topic">The topic URI.</param>
        /// <param name="publisher">The publisher (for event flow and logging).</param>
        /// <param name="handlerRestriction">The handler restriction.</param>
        /// <param name="sender">The sender (passed to the event handler).</param>
        /// <param name="eventArgs">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public void Fire(string topic, object publisher, HandlerRestriction handlerRestriction, object sender, EventArgs eventArgs)
        {
            Ensure.ArgumentNotNull(eventArgs, "eventArgs");

            IEventTopic eventTopic = this.eventTopicHost.GetEventTopic(topic);
            using (var spontaneousPublication = new SpontaneousPublication(eventTopic, publisher, eventArgs.GetType(), handlerRestriction, new List<IPublicationMatcher>()))
            {
                eventTopic.AddPublication(spontaneousPublication);

                eventTopic.Fire(sender, eventArgs, spontaneousPublication);

                eventTopic.RemovePublication(publisher, SpontaneousPublication.SpontaneousEventName);
            }
        }