From be59baaa024f8c5f02ec14fe34155e736548046b Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 9 Nov 2016 13:29:55 +0100 Subject: * BCDD code for parsing PBN files added --- Aktywator/PBNFile.cs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Aktywator/PBNFile.cs (limited to 'Aktywator/PBNFile.cs') diff --git a/Aktywator/PBNFile.cs b/Aktywator/PBNFile.cs new file mode 100644 index 0000000..044630a --- /dev/null +++ b/Aktywator/PBNFile.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; + +namespace Aktywator +{ + class PBNFile + { + public List Boards; + + private String filename; + + public PBNFile(String filename) + { + this.filename = filename; + this.Boards = new List(); + String[] fileContents = File.ReadAllLines(this.filename); + List contents = new List(); + foreach (String line in fileContents) { + contents.Add(line.Trim()); + } + List lines = new List(); + foreach (String line in contents) + { + if (line.Length == 0) + { + if (lines.Count > 0) + { + this.Boards.Add(new PBNBoard(lines)); + lines = new List(); + } + } + else + { + lines.Add(line); + } + } + if (lines.Count > 0) + { + this.Boards.Add(new PBNBoard(lines)); + } + } + + } +} -- cgit v1.2.3