From 8431063bc8f8ad06e896677bbfae6a6dfe3317fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Fri, 4 Apr 2014 09:13:21 +0200 Subject: [PATCH] Parser.Block.GetBoolValue(string) implementiert + weitere compilefehler beseitigt --- src/Parser.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Parser.cs b/src/Parser.cs index ab68042..63affbe 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -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 Buffer = new Queue (); private AutoResetEvent BufferFilledEvent = new AutoResetEvent (false); private Thread ParserThread; - private LinkedList message; + private LinkedList Message; private Regex LastLineRegex; public Parser () { ParserThread = new Thread (new ThreadStart (this.RunParser)); - message = new LinkedList (); + Message = new LinkedList (); 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]); + } } } }