1
|
//
|
2
|
// Author: Eliska Mourycova
|
3
|
//
|
4
|
|
5
|
using System;
|
6
|
using System.Collections.Generic;
|
7
|
using System.Linq;
|
8
|
using System.Text;
|
9
|
using System.Threading.Tasks;
|
10
|
|
11
|
namespace ServerApp.User
|
12
|
{
|
13
|
/// <summary>
|
14
|
/// This class represents a command input by the admin
|
15
|
/// </summary>
|
16
|
public class Command
|
17
|
{
|
18
|
/// <summary>
|
19
|
/// The whole string input
|
20
|
/// </summary>
|
21
|
public string WholeCommand { get; set; }
|
22
|
|
23
|
/// <summary>
|
24
|
/// The main part of the command
|
25
|
/// </summary>
|
26
|
public string MainCommand { get; set; }
|
27
|
|
28
|
/// <summary>
|
29
|
/// The flags and data associated with the command
|
30
|
/// </summary>
|
31
|
public Dictionary<string, List<string>> FlagsAndData { get; }
|
32
|
|
33
|
// the last flag used
|
34
|
private string lastFlag;
|
35
|
|
36
|
public Command()
|
37
|
{
|
38
|
MainCommand = "";
|
39
|
FlagsAndData = new Dictionary<string, List<string>>();
|
40
|
lastFlag = "";
|
41
|
}
|
42
|
|
43
|
/// <summary>
|
44
|
/// Adds a flag to the dictionary
|
45
|
/// </summary>
|
46
|
/// <param name="flag">The flag to add</param>
|
47
|
public void AddFlag(string flag)
|
48
|
{
|
49
|
FlagsAndData.Add(flag, new List<string>());
|
50
|
lastFlag = flag;
|
51
|
}
|
52
|
|
53
|
/// <summary>
|
54
|
/// Adds data after a flag
|
55
|
/// </summary>
|
56
|
/// <param name="data">The data to add</param>
|
57
|
public void AddData(string data)
|
58
|
{
|
59
|
if(FlagsAndData.ContainsKey(lastFlag))
|
60
|
FlagsAndData[lastFlag].Add(data);
|
61
|
}
|
62
|
}
|
63
|
}
|