FromActorRef() public static method

public static FromActorRef ( IActorRef actorRef ) : Routee
actorRef IActorRef
return Routee
Example #1
0
        //The signature might look funky. Why not just Router(RoutingLogic logic, params ActorRef[] routees) ?
        //We need one unique constructor to handle this call: new Router(logic). The other constructor will handle that.
        //So in order to not confuse the compiler we demand at least one ActorRef. /@hcanber
        public Router(RoutingLogic logic, IActorRef routee, params IActorRef[] routees)
        {
            var routeesLength = routees.Length;

            if (routees == null || routeesLength == 0)
            {
                _routees = new[] { Routee.FromActorRef(routee) };
            }
            else
            {
                //Convert and put routee first in a new array
                var rts = new Routee[routeesLength + 1];
                rts[0] = Routee.FromActorRef(routee);

                //Convert all routees and put them into the new array
                for (var i = 0; i < routeesLength; i++)
                {
                    var actorRef = routees[i];
                    var r        = Routee.FromActorRef(actorRef);
                    rts[i + 1] = r;
                }
                _routees = rts;
            }
            _logic = logic;
        }