Ejemplo n.º 1
0
    internal static ActorProtocolActor <T>[] AllOf(T[] protocolActors, Actor actor)
    {
        var all = new ActorProtocolActor <T> [protocolActors.Length];

        for (int idx = 0; idx < protocolActors.Length; ++idx)
        {
            all[idx] = new ActorProtocolActor <T>(actor, protocolActors[idx]);
        }
        return(all);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Answers a <c>Protocols</c> that provides one or more supported <paramref name="protocols"/> for the
    /// newly created <c>Actor</c> according to <paramref name="definition"/>.
    /// </summary>
    /// <param name="protocols">The array of protocol that the <c>Actor</c> supports.</param>
    /// <param name="definition">The <c>Definition</c> providing parameters to the <c>Actor</c>.</param>
    /// <returns>A <see cref="Protocols"/> instance.</returns>
    public Protocols ActorFor(Type[] protocols, Definition definition)
    {
        var all = ActorProtocolFor(
            protocols,
            definition,
            definition.ParentOr(World.DefaultParent),
            definition.Supervisor,
            definition.LoggerOr(World.DefaultLogger));

        return(new Protocols(ActorProtocolActor <object> .ToActors(all)));
    }
Ejemplo n.º 3
0
    internal static object[] ToActors(ActorProtocolActor <object>[]?all)
    {
        if (all == null)
        {
            return(new object[0]);
        }

        var actors = new object[all.Length];

        for (int idx = 0; idx < all.Length; ++idx)
        {
            actors[idx] = all[idx].ProtocolActor;
        }
        return(actors);
    }
Ejemplo n.º 4
0
    internal static object[] ToTestActors(ActorProtocolActor <T>[]?all, Type[] protocols)
    {
        if (all == null)
        {
            return(new object[0]);
        }

        var testActors = new object[all.Length];

        for (int idx = 0; idx < all.Length; ++idx)
        {
            testActors[idx] = all[idx].ToTestActor(protocols[idx]);
        }

        return(testActors);
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Answers a <c>Protocols</c> that provides one or more supported <paramref name="protocols"/> for the
    /// newly created <c>Actor</c> according to <paramref name="definition"/>, that can be used for testing.
    /// Test-based <c>Actor</c> instances are backed by the synchronous <c>TestMailbox</c>.
    /// </summary>
    /// <param name="protocols">The array of protocols that the <c>Actor</c> supports.</param>
    /// <param name="definition">The <c>Definition</c> providing parameters to the <c>Actor</c>.</param>
    /// <returns></returns>
    internal Protocols TestActorFor(Type[] protocols, Definition definition)
    {
        var redefinition = Definition.Has(
            definition.Type,
            definition.Parameters(),
            TestMailbox.Name,
            definition.ActorName);

        var all = ActorProtocolFor(
            protocols,
            redefinition,
            definition.ParentOr(World.DefaultParent),
            null,
            null,
            definition.Supervisor,
            definition.LoggerOr(World.DefaultLogger));

        return(new Protocols(ActorProtocolActor <object> .ToTestActors(all, protocols)));
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Answers a <code>Protocols</code> that provides one or more supported <paramref name="protocols"/> for the
    /// newly created <code>Actor</code> according to <paramref name="definition"/>.
    /// </summary>
    /// <param name="protocols">Array of protocols that the <code>Actor</code> supports.</param>
    /// <param name="definition">The definition providing parameters to the <code>Actor</code>.</param>
    /// <param name="parent">The actor that is this actor's parent.</param>
    /// <param name="maybeSupervisor">The possible supervisor of this actor.</param>
    /// <param name="logger">The logger of this actor.</param>
    /// <returns></returns>
    public Protocols ActorFor(Type[] protocols, Definition definition, Actor parent, ISupervisor?maybeSupervisor, ILogger logger)
    {
        var all = ActorProtocolFor(protocols, definition, parent, maybeSupervisor, logger);

        return(new Protocols(ActorProtocolActor <object> .ToActors(all)));
    }