Пример #1
0
        public static IServiceCollection AddActorReference <TActor>(
            this IServiceCollection builder, IActorRef actorReference)
            where TActor : ActorBase
        {
            var actorRef = new ActorRefProvider <TActor>(actorReference);

            builder.AddSingleton <ActorRefProvider <TActor> >(actorRef);
            return(builder);
        }
Пример #2
0
        public static IServiceCollection AddActorReference <TActor>(
            this IServiceCollection builder, Func <IServiceProvider, Props> actionProvider)
            where TActor : ActorBase
        {
            builder.AddSingleton <ActorRefProvider <TActor> >(provider =>
            {
                var system     = provider.GetService <ActorSystem>();
                var actorProps = actionProvider(provider);
                var actorRef   = new ActorRefProvider <TActor>(system.ActorOf(actorProps));

                return(actorRef);
            });
            return(builder);
        }
 public static Task <T> Ask <T>(this ActorRefProvider provider, Func <IActorRef, object> messageFactory, TimeSpan?timeout, CancellationToken cancellationToken)
 {
     return(provider.ActorRef.Ask <T>(messageFactory, timeout, cancellationToken));
 }
 public static Task <T> Ask <T>(this ActorRefProvider provider, object message, CancellationToken cancellationToken)
 {
     return(provider.ActorRef.Ask <T>(message, cancellationToken));
 }
 public static Task <T> Ask <T>(this ActorRefProvider provider, object message, TimeSpan?timeout = null)
 {
     return(provider.ActorRef.Ask <T>(message, timeout));
 }
 public static Task <object> Ask(this ActorRefProvider provider, object message, TimeSpan?timeout, CancellationToken cancellationToken)
 {
     return(provider.ActorRef.Ask(message, timeout, cancellationToken));
 }
 public static void Tell(this ActorRefProvider provider, object message)
 {
     provider.ActorRef.Tell(message, ActorRefs.NoSender);
 }