Parser.Block.GetBoolValue(string) implementiert + weitere compilefehler beseitigt

This commit is contained in:
2014-04-04 09:13:21 +02:00
parent a09f936de6
commit 8431063bc8

View File

@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Threading;
using System.Collections.Generic;
using System.Text.RegularExpressions;
@@ -10,13 +11,13 @@ namespace WorldOfPeacecraft
private Queue<string> Buffer = new Queue<string> ();
private AutoResetEvent BufferFilledEvent = new AutoResetEvent (false);
private Thread ParserThread;
private LinkedList<string> message;
private LinkedList<string> Message;
private Regex LastLineRegex;
public Parser ()
{
ParserThread = new Thread (new ThreadStart (this.RunParser));
message = new LinkedList<string> ();
Message = new LinkedList<string> ();
LastLineRegex = new Regex ("^end:[0-9]+$");
}
@@ -33,7 +34,7 @@ namespace WorldOfPeacecraft
if (waitRequired)
BufferFilledEvent.WaitOne ();
lock (Buffer) {
message.AddLast (Buffer.Dequeue ());
Message.AddLast (Buffer.Dequeue ());
}
}
}
@@ -43,7 +44,8 @@ namespace WorldOfPeacecraft
// If package is not complete wait for more lines
if (!IsCompletePackage ())
return;
Block mainBlock = new Block (message, 0, message.Count - 1);
String[] aMessage = Enumerable.ToArray(Message);
Block mainBlock = new Block (aMessage, 0, aMessage.Length - 1);
MapData (mainBlock);
}
@@ -54,7 +56,7 @@ namespace WorldOfPeacecraft
private bool IsCompletePackage ()
{
string lastLine = message.Last.Value;
string lastLine = Message.Last.Value;
return LastLineRegex.IsMatch (lastLine);
}
@@ -132,6 +134,11 @@ namespace WorldOfPeacecraft
{
return long.Parse (Values [name]);
}
public bool GetBoolValue (string name)
{
return bool.Parse (Values [name]);
}
}
}
}