-
Notifications
You must be signed in to change notification settings - Fork 0
/
InputValidatorActor.cs
30 lines (27 loc) · 1.11 KB
/
InputValidatorActor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using Akka.Actor;
namespace WinTailC {
public class InputValidatorActor : UntypedActor {
IActorRef _consoleWriterActor;
public InputValidatorActor(IActorRef consoleWriterActor) {
_consoleWriterActor = consoleWriterActor;
}
protected override void OnReceive(object message) {
switch (message) {
case String input when string.IsNullOrEmpty(input):
_consoleWriterActor.Tell(new EmptyInput("Your input had no characters"));
break;
case String input when input.Length % 2 == 0:
_consoleWriterActor.Tell(new ValidInput("Your input had an even number of characters"));
break;
case String input when input.Length % 2 != 0:
_consoleWriterActor.Tell(new InvalidInput("Your input had an odd number of characters"));
break;
default:
base.Unhandled(message);
break;
}
base.Sender.Tell(new ContinueProcessing());
}
}
}