-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserInterfaceExampleBoundedAccess.cs
More file actions
51 lines (38 loc) · 1.49 KB
/
UserInterfaceExampleBoundedAccess.cs
File metadata and controls
51 lines (38 loc) · 1.49 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using Core.Extensions;
using GofConsoleApp.Examples.Structural.ProxyPattern.UserInterfaceComponents;
using static GofConsoleApp.Examples.Structural.ProxyPattern.UserInterfaceComponents.EnumUserType;
namespace GofConsoleApp.Examples.Structural.ProxyPattern;
internal class UserInterfaceExampleBoundedAccess : BaseExample
{
protected override bool Execute()
{
Logger.Log("user types", new[] { Admin, Standard, Guest });
var input = AcceptInputEnum(Invalid, "user type");
if (input.Equals(Invalid))
return false;
IUserInterface userInterface = new UserInterface();
IUserInterfaceProxy proxy = input switch
{
Admin => new UserInterfaceProxyAdmin(userInterface),
Standard => new UserInterfaceProxyStandard(userInterface),
_ => new UserInterfaceProxyGuest(userInterface)
};
Logger.Log("operation commands", proxy.BoundedInputs.ToList());
ExecuteUserInterface(proxy);
return true;
}
private void ExecuteUserInterface(IUserInterface userInterface)
{
while (true)
{
var input = AcceptInputEnum(EnumOperationOption.Invalid, "operation command");
if (input.Equals(EnumOperationOption.Invalid))
{
Logger.Log($"Quitting due to user input: {input}");
return;
}
var commandOutput = userInterface.Process(input);
Logger.Log(commandOutput);
}
}
}