Projekt

Obecné

Profil

Stáhnout (1.2 KB) Statistiky
| Větev: | Tag: | Revize:
1
//
2
// Author: Eliska Mourycova
3
//
4

    
5
using System.Collections.Generic;
6

    
7
namespace ServerApp.User
8
{
9
	/// <summary>
10
	/// This class represents a command input by the admin
11
	/// </summary>
12
	public class Command
13
	{
14
		/// <summary>
15
		/// The whole string input
16
		/// </summary>
17
		public string WholeCommand { get; set; }
18

    
19
		/// <summary>
20
		/// The main part of the command
21
		/// </summary>
22
		public string MainCommand { get; set; }
23

    
24
		/// <summary>
25
		/// The flags and data associated with the command
26
		/// </summary>
27
		public Dictionary<string, List<string>> FlagsAndData { get; }
28

    
29
		// the last flag used
30
		private string lastFlag;
31

    
32
		public Command()
33
		{
34
			MainCommand = "";
35
			FlagsAndData = new Dictionary<string, List<string>>();
36
			lastFlag = "";
37
		}
38

    
39
		/// <summary>
40
		/// Adds a flag to the dictionary
41
		/// </summary>
42
		/// <param name="flag">The flag to add</param>
43
		public void AddFlag(string flag)
44
		{
45
			FlagsAndData.Add(flag, new List<string>());
46
			lastFlag = flag;
47
		}
48

    
49
		/// <summary>
50
		/// Adds data after a flag
51
		/// </summary>
52
		/// <param name="data">The data to add</param>
53
		public void AddData(string data)
54
		{
55
			if(FlagsAndData.ContainsKey(lastFlag))
56
				FlagsAndData[lastFlag].Add(data);
57
		}
58
	}
59
}
(1-1/2)