6237 Programmering II (Csharp) Agenda/Sprint2

From Teknologisk videncenter
Jump to: navigation, search

Sprint 2

Nu burde i være klar til at løse sprint 2.

Start med at lave klassen "Log" som indeholder attributterne Protokoltype, SourceIP og DestinationIP.

class Log
{
	private string source;
	public string Source
	{
		get { return source; }
		set { source = value; }
	}

	private string destination;
	public string Destination
	{
		get { return destination; }
		set { destination = value; }
	}

	private string protocol;
	public string Protocol
	{
		get { return protocol; }
		set { protocol = value; }
	}

	public Log(string source, string destination, string protocol)
	{
		this.source = source;
		this.destination = destination;
		this.protocol = protocol;
	}
}

Ret derefter analyze så den gemmer alle data i en List<Log>.

static List<Log> logs = new List<Log>();
static void analyze(List<String> lines)
{
	if (lines.Count < 2) return;
	String protocol = lines[1].Substring(67, 9);
	String source = lines[1].Substring(22, 23);
	String destination = lines[1].Substring(44, 23);
	Log log = new Log(source, destination, protocol);
	logs.Add(log);
	.....
	.....

Herefter laver i søgefunktioner til listen som kan finde bestemte logs ud fra forskellige parametre(DNS, SourceIP, DestinationIP.

Når dette er gjort laver i en specialisering af klassen log som i kalder DNS, den tilføjes attributten webaddress.

Lav til sidst en søgning på webaddress.