Skip to content

Commit 171d17a

Browse files
committed
Adding method where actor created without args.
Moved some methods around to group better
1 parent a511842 commit 171d17a

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

src/core/Akka/Actor/Props.cs

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -346,34 +346,21 @@ public static Props Create<TActor>(Func<TActor> factory, SupervisorStrategy supe
346346
/// Creates an actor using the given arguments.
347347
/// </summary>
348348
/// <typeparam name="TActor">The type of the actor to create.</typeparam>
349-
/// <param name="args">The arguments needed to create the actor.</param>
350349
/// <returns>The newly created <see cref="Akka.Actor.Props" />.</returns>
351-
public static Props Create<TActor>(params object[] args) where TActor : ActorBase
350+
public static Props Create<TActor>() where TActor : ActorBase, new()
352351
{
353-
return new Props(new ActivatorProducer(typeof(TActor), args), DefaultDeploy, args);
352+
return new Props(new FactoryProducer<TActor>(() => new TActor()), DefaultDeploy, NoArgs);
354353
}
355354

356355
/// <summary>
357-
/// Creates an actor using a specified actor producer.
358-
/// </summary>
359-
/// <typeparam name="TProducer">The type of producer used to create the actor.</typeparam>
360-
/// <param name="args">The arguments needed to create the actor.</param>
361-
/// <returns>The newly created <see cref="Akka.Actor.Props" />.</returns>
362-
[Obsolete("Do not use this method. Call CreateBy(IIndirectActorProducer, params object[] args) instead")]
363-
public static Props CreateBy<TProducer>(params object[] args) where TProducer : class, IIndirectActorProducer
364-
{
365-
return new Props(typeof(TProducer), args);
366-
}
367-
368-
/// <summary>
369-
/// Creates an actor using a specified actor producer.
356+
/// Creates an actor using the given arguments.
370357
/// </summary>
371-
/// <param name="producer">The actor producer that will be used to create the underlying actor..</param>
358+
/// <typeparam name="TActor">The type of the actor to create.</typeparam>
372359
/// <param name="args">The arguments needed to create the actor.</param>
373360
/// <returns>The newly created <see cref="Akka.Actor.Props" />.</returns>
374-
public static Props CreateBy(IIndirectActorProducer producer, params object[] args)
361+
public static Props Create<TActor>(params object[] args) where TActor : ActorBase
375362
{
376-
return new Props(producer, DefaultDeploy, args);
363+
return new Props(new ActivatorProducer(typeof(TActor), args), DefaultDeploy, args);
377364
}
378365

379366
/// <summary>
@@ -402,6 +389,29 @@ public static Props Create(Type type, params object[] args)
402389
return new Props(type, args);
403390
}
404391

392+
/// <summary>
393+
/// Creates an actor using a specified actor producer.
394+
/// </summary>
395+
/// <typeparam name="TProducer">The type of producer used to create the actor.</typeparam>
396+
/// <param name="args">The arguments needed to create the actor.</param>
397+
/// <returns>The newly created <see cref="Akka.Actor.Props" />.</returns>
398+
[Obsolete("Do not use this method. Call CreateBy(IIndirectActorProducer, params object[] args) instead")]
399+
public static Props CreateBy<TProducer>(params object[] args) where TProducer : class, IIndirectActorProducer
400+
{
401+
return new Props(typeof(TProducer), args);
402+
}
403+
404+
/// <summary>
405+
/// Creates an actor using a specified actor producer.
406+
/// </summary>
407+
/// <param name="producer">The actor producer that will be used to create the underlying actor..</param>
408+
/// <param name="args">The arguments needed to create the actor.</param>
409+
/// <returns>The newly created <see cref="Akka.Actor.Props" />.</returns>
410+
public static Props CreateBy(IIndirectActorProducer producer, params object[] args)
411+
{
412+
return new Props(producer, DefaultDeploy, args);
413+
}
414+
405415
/// <summary>
406416
/// Creates a new <see cref="Akka.Actor.Props" /> with a given <paramref name="mailbox" />.
407417
/// <note>

0 commit comments

Comments
 (0)