Skip to content

Instantly share code, notes, and snippets.

@Eugeny
Created October 29, 2011 07:51
Show Gist options
  • Save Eugeny/1324212 to your computer and use it in GitHub Desktop.
Save Eugeny/1324212 to your computer and use it in GitHub Desktop.
public static Test ReadFromTxt(string fileName)
{
Test t = null;
using (Stream s = File.OpenRead(fileName))
{
using (StreamReader sr = new StreamReader(s))
{
string name = sr.ReadLine();
t = new Test(name.SubString(6));
Question q = null;
while (true) {
string s = sr.ReadLine();
if (s==null)return;
if (s.StartsWith("<")) {
q = new Question(s.SubString(2));
t.AddQuestionLOL(q);
}
if (s.StartsWith("--")) {
string[] ss = s.Split(":");
Variant v = new Variant(ss[0].SubString(2).Trim(), ss[1].Trim());
q.AddVariantWTFLOL(v);
}
}
return t;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment