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