Esempio n. 1
0
        /// <summary>
        /// Unsubscribe from a published actor event.
        /// </summary>
        /// <typeparam name="TEvent">The type of the event interface.</typeparam>
        /// <param name="actorProxy">The actor that publishes the event.</param>
        /// <param name="subscriber">The subscriber that receives the event.</param>
        /// <returns>A task that represents the asynchronous operation of un-subscribing from a published actor event.</returns>
        /// <exception cref="System.ArgumentException">
        /// <para>When actorProxy is not of type <see cref="ActorProxy"/></para>.
        /// <para>When TEvent doesn't implement <see cref="IActorEvents"/></para>
        /// </exception>
        public static Task UnsubscribeAsync <TEvent>(this IActorEventPublisher actorProxy, TEvent subscriber)
        {
            var proxy = actorProxy as ActorProxy;

            if (proxy == null)
            {
                throw new ArgumentException(SR.ActorProxyOnlyMethod, "actorProxy");
            }
            var eventInterfaceType = GetEventInterface(typeof(TEvent));

            if (eventInterfaceType == null)
            {
                throw new ArgumentException(SR.ErrorEventInterface);
            }
            return(proxy.UnsubscribeAsync(eventInterfaceType, subscriber));
        }
Esempio n. 2
0
        /// <summary>
        /// Subscribe to a published actor event.
        /// </summary>
        /// <typeparam name="TEvent">The type of the event interface.</typeparam>
        /// <param name="actorProxy">The actor that publishes the event.</param>
        /// <param name="subscriber">The subscriber that receives the events.</param>
        /// <param name="resubscriptionInterval">The time between re-subscription attempts.</param>
        /// <returns>A task that represents the asynchronous operation of subscribing to a published actor event.</returns>
        /// <exception cref="System.ArgumentException">
        /// <para>When actorProxy is not of type <see cref="ActorProxy"/></para>.
        /// </exception>
        public static async Task SubscribeAsync <TEvent>(
            this IActorEventPublisher actorProxy,
            TEvent subscriber,
            TimeSpan resubscriptionInterval) where TEvent : IActorEvents
        {
            var proxy = actorProxy as ActorProxy;

            if (proxy == null)
            {
                throw new ArgumentException(SR.ActorProxyOnlyMethod, "actorProxy");
            }

            var eventInterfaceType = GetEventInterface(typeof(TEvent));

            if (eventInterfaceType == null)
            {
                throw new ArgumentException(SR.ErrorEventInterface);
            }
            await proxy.SubscribeAsync(eventInterfaceType, subscriber, resubscriptionInterval);
        }
 /// <inheritdoc />
 public Task UnsubscribeAsync <TEvent>(IActorEventPublisher actorProxy, TEvent subscriber) where TEvent : IActorEvents
 {
     return(actorProxy.UnsubscribeAsync(subscriber));
 }
Esempio n. 4
0
 /// <summary>
 /// Subscribe to a published actor event.
 /// </summary>
 /// <typeparam name="TEvent">The type of the event interface.</typeparam>
 /// <param name="actorProxy">The actor that publishes the event.</param>
 /// <param name="subscriber">The subscriber that receives the events.</param>
 /// <returns>A task that represents the asynchronous operation of subscribing to a published actor event.</returns>
 /// <exception cref="System.ArgumentException">
 /// <para>When actorProxy is not of type <see cref="ActorProxy"/></para>.
 /// </exception>
 public static Task SubscribeAsync <TEvent>(
     this IActorEventPublisher actorProxy,
     TEvent subscriber) where TEvent : IActorEvents
 {
     return(SubscribeAsync(actorProxy, subscriber, DefaultResubscriptionInternal));
 }
 /// <inheritdoc />
 public Task SubscribeAsync <TEvent>(IActorEventPublisher actorProxy, TEvent subscriber, TimeSpan resubscriptionInterval) where TEvent : IActorEvents
 {
     return(actorProxy.SubscribeAsync(subscriber, resubscriptionInterval));
 }
 /// <inheritdoc />
 public Task UnsubscribeAsync <TEvent>(IActorEventPublisher actorProxy, TEvent subscriber)
     where TEvent : IActorEvents
 {
     _subscribers.Remove(subscriber);
     return(_completed);
 }
 /// <inheritdoc />
 public Task SubscribeAsync <TEvent>(IActorEventPublisher actorProxy, TEvent subscriber, TimeSpan resubscriptionInterval)
     where TEvent : IActorEvents
 {
     _subscribers.Add(subscriber);
     return(_completed);
 }
 /// <inheritdoc />
 public Task UnsubscribeAsync <TEvent>(IActorEventPublisher actorProxy, TEvent subscriber)
 {
     return(_completed);
 }
 /// <inheritdoc />
 public Task SubscribeAsync <TEvent>(IActorEventPublisher actorProxy, TEvent subscriber)
     where TEvent : IActorEvents
 {
     return(_completed);
 }