Line data Source code
1 : #region Copyright
2 : // // -----------------------------------------------------------------------
3 : // // <copyright company="Chinchilla Software Limited">
4 : // // Copyright Chinchilla Software Limited. All rights reserved.
5 : // // </copyright>
6 : // // -----------------------------------------------------------------------
7 : #endregion
8 :
9 : using System;
10 : using Akka.Actor;
11 : using Cqrs.Akka.Domain;
12 : using Cqrs.Akka.Tests.Unit.Aggregates;
13 : using Cqrs.Commands;
14 : using Cqrs.Domain;
15 :
16 : namespace Cqrs.Akka.Tests.Unit.Commands.Handlers
17 : {
18 : /// <summary>
19 : /// Handles the <see cref="SayHelloWorldCommand"/>.
20 : /// </summary>
21 : public class SayHelloWorldCommandHandler
22 : : ICommandHandler<Guid, SayHelloWorldCommand>
23 1 : {
24 : /// <summary>
25 : /// Instantiates the <see cref="SayHelloWorldCommandHandler"/> class registering any <see cref="ReceiveActor.Receive{T}(System.Func{T,System.Threading.Tasks.Task})"/> required.
26 : /// </summary>
27 1 : public SayHelloWorldCommandHandler(IAkkaAggregateResolver aggregateResolver)
28 : {
29 : AggregateResolver = aggregateResolver;
30 : }
31 :
32 : /// <summary>
33 : /// Resolves Akka.Net actor based <see cref="IAggregateRoot{TAuthenticationToken}"/>
34 : /// </summary>
35 : protected IAkkaAggregateResolver AggregateResolver { get; private set; }
36 :
37 : #region Implementation of IMessageHandler<in SayHelloWorldCommand>
38 :
39 : /// <summary>
40 : /// Responds to the provided <paramref name="command"/>.
41 : /// </summary>
42 : /// <param name="command">The <see cref="SayHelloWorldCommand"/> to respond to or "handle"</param>
43 1 : public void Handle(SayHelloWorldCommand command)
44 : {
45 : if (command.Id == Guid.Empty)
46 : command.Id = Guid.NewGuid();
47 : IActorRef item = AggregateResolver.ResolveActor<HelloWorld, Guid>(command.Id);
48 : bool result = item.Ask<bool>(command).Result;
49 : // item.Tell(parameters);
50 : }
51 :
52 : #endregion
53 : }
54 : }
|