Пример #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="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public void Fire(string topic, object publisher, HandlerRestriction handlerRestriction, object sender, EventArgs e)
        {
            IEventTopic eventTopic = this.eventTopicHost.GetEventTopic(topic);

            eventTopic.Fire(
                sender,
                e,
                new SpontaneousPublication(eventTopic, publisher, e.GetType(), handlerRestriction, new List <IPublicationMatcher>()));
        }
Пример #2
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(spontaneousPublication);
            }
        }
Пример #3
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)
        {
            Guard.AgainstNullArgument(nameof(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);
            }
        }