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="ReplyToHelloWorldCommand"/>.
20 : /// </summary>
21 : public class ReplyToHelloWorldCommandHandler
22 : : ICommandHandler<Guid, ReplyToHelloWorldCommand>
23 1 : {
24 : /// <summary>
25 : /// Instantiates the <see cref="ReplyToHelloWorldCommandHandler"/> class registering any <see cref="ReceiveActor.Receive{T}(System.Func{T,System.Threading.Tasks.Task})"/> required.
26 : /// </summary>
27 1 : public ReplyToHelloWorldCommandHandler(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 ReplyToHelloWorldCommand>
38 :
39 : /// <summary>
40 : /// Responds to the provided <paramref name="command"/>.
41 : /// </summary>
42 : /// <param name="command">The <see cref="ReplyToHelloWorldCommand"/> to respond to or "handle"</param>
43 1 : public void Handle(ReplyToHelloWorldCommand command)
44 : {
45 : IActorRef item = AggregateResolver.ResolveActor<HelloWorld, Guid>(command.Id);
46 : bool result = item.Ask<bool>(command).Result;
47 : // item.Tell(parameters);
48 : }
49 :
50 : #endregion
51 : }
52 : }
|