summaryrefslogtreecommitdiff
path: root/Aktywator/PBNFile.cs
blob: 044630a77ea706cce9efadf9375d621b2232b69d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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));
            }
        }

    }
}