summaryrefslogtreecommitdiff
path: root/Aktywator/PBNFile.cs
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-11-09 13:29:55 +0100
committeremkael <emkael@tlen.pl>2016-11-14 14:46:01 +0100
commitbe59baaa024f8c5f02ec14fe34155e736548046b (patch)
tree3c4f136c234f940d841373c26d1ee5ccbec340d8 /Aktywator/PBNFile.cs
parent64b9dce9855ecbceaa32a7d07f71490d5549fdfb (diff)
* BCDD code for parsing PBN files added
Diffstat (limited to 'Aktywator/PBNFile.cs')
-rw-r--r--Aktywator/PBNFile.cs46
1 files changed, 46 insertions, 0 deletions
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<PBNBoard> Boards;
+
+ private String filename;
+
+ public PBNFile(String filename)
+ {
+ this.filename = filename;
+ this.Boards = new List<PBNBoard>();
+ String[] fileContents = File.ReadAllLines(this.filename);
+ List<String> contents = new List<String>();
+ foreach (String line in fileContents) {
+ contents.Add(line.Trim());
+ }
+ List<String> lines = new List<String>();
+ foreach (String line in contents)
+ {
+ if (line.Length == 0)
+ {
+ if (lines.Count > 0)
+ {
+ this.Boards.Add(new PBNBoard(lines));
+ lines = new List<String>();
+ }
+ }
+ else
+ {
+ lines.Add(line);
+ }
+ }
+ if (lines.Count > 0)
+ {
+ this.Boards.Add(new PBNBoard(lines));
+ }
+ }
+
+ }
+}