Commits

Anonymous committed fcb8351

Refactoring: Moved common methods and events from Boost/QtBuildProcess to
BuildProcess.

Comments (0)

Files changed (5)

BlueGo.suo

Binary file modified.
 
                 message("boost successfully built!");
 
-                if (Finished != null)
-                {
-                    Finished(this);
-                }
+                OnFinished();
             }
             catch (Exception ex)
             {
             }
         }
 
-        public event MessageEventHandler Message;
-        public event StandardOutputMessageEventHandler StandardOutputMessage;
-        public event StandardErrorMessageEventHandler StandardErrorMessage;
-        public event FinishedEventHandler Finished;
-
-        void message(string msg)
-        {
-            if(Message != null)
-                Message(this, msg);
-        }
-
-        private void readStandardOutput(Process p)
-        {
-            using (StreamReader sr = p.StandardOutput)
-            {
-                while (sr.BaseStream.CanRead)
-                {
-                    string test = sr.ReadLine();
-
-                    if (test == null)
-                        break;
-
-                    if (StandardOutputMessage != null)
-                    {
-                        StandardOutputMessage(this, test);
-                    }
-                }
-            }
-        }
-
-        private void readStandardError(Process p)
-        {
-            using (StreamReader sr = p.StandardError)
-            {
-                while (sr.BaseStream.CanRead)
-                {
-                    string test = sr.ReadLine();
-
-                    if (test == null)
-                        break;
-
-                    if (StandardErrorMessage != null)
-                    {
-                        StandardErrorMessage(this, test);
-                    }
-                }
-            }
-        }
-
         private void buildBoost_1_51_0_x64(string destinationFolder)
         {
             Process p = new Process();

BlueGo/BuildProcess.cs

 {
     class BuildProcess
     {
+        public event MessageEventHandler Message;
+        public event StandardOutputMessageEventHandler StandardOutputMessage;
+        public event StandardErrorMessageEventHandler StandardErrorMessage;
+        public event FinishedEventHandler Finished;
+
+        protected void readStandardOutput(Process p)
+        {
+            using (StreamReader sr = p.StandardOutput)
+            {
+                while (sr.BaseStream.CanRead)
+                {
+                    string test = sr.ReadLine();
+
+                    if (test == null)
+                        break;
+
+                    if (StandardOutputMessage != null)
+                    {
+                        StandardOutputMessage(this, test);
+                    }
+                }
+            }
+        }
+
+        protected void readStandardError(Process p)
+        {
+            using (StreamReader sr = p.StandardError)
+            {
+                while (sr.BaseStream.CanRead)
+                {
+                    string test = sr.ReadLine();
+
+                    if (test == null)
+                        break;
+
+                    if (StandardErrorMessage != null)
+                    {
+                        StandardErrorMessage(this, test);
+                    }
+                }
+            }
+        }
+
+        protected void message(string msg)
+        {
+            if (Message != null)
+                Message(this, msg);
+        }
+
+        protected void OnFinished()
+        {
+            if (Finished != null)
+            {
+                Finished(this);
+            }
+        }
+
         public ProcessStartInfo CreateVisualStudioCommandPromptProcessStartInfo(eCompiler compilerType, ePlatform platformType)
         {
             ProcessStartInfo info = null;

BlueGo/FormMain.cs

 
             }
                  
-            /*
-            Thread t = new Thread(new ThreadStart(DownloadAndBuildQT4_8_3_x64));
-            t.Start();
-            */
-
             qtBuildProcessDescripton qbpd = new qtBuildProcessDescripton();
             qbpd.qtVersion = DetermineSelectedQtVersion();
             qbpd.compilerType = compiler;
             qbpd.destinationFolder = DetermineDestinationFolder();
             QtBuildProcess qtBuildProcess = new QtBuildProcess(qbpd);
 
+       
             qtBuildProcess.Message += new MessageEventHandler(qtBuildProcess_Message);
             qtBuildProcess.StandardOutputMessage += new StandardOutputMessageEventHandler(qtBuildProcess_StandardOutputMessage);
             qtBuildProcess.StandardErrorMessage += new StandardErrorMessageEventHandler(qtBuildProcess_StandardErrorMessage);
             Thread workerThread = new Thread(qtBuildProcess.DownloadAndBuildQT_x64);
             workerThread.Start();
         }
-
+        
         void qtBuildProcess_Finished(object sender)
         {
             UnlockQtBuildButton();
 
             // Lock GUI
             buttonBoostBuild.Enabled = false;
-
-            /*
-            Thread t = new Thread(new ThreadStart(DownloadAndBuildBoost_x64));
-            t.Start();
-            */
-
+            
             boostBuildProcessDescripton bbpd = new boostBuildProcessDescripton();
             bbpd.boostVersion = DetermineSelectedBoostVersion();
             bbpd.compilerType = compiler;
             platform = qbpd.platform;
         }
 
-        public event MessageEventHandler Message;
-        public event StandardOutputMessageEventHandler StandardOutputMessage;
-        public event StandardErrorMessageEventHandler StandardErrorMessage;
-        public event FinishedEventHandler Finished;
-
-        void message(string msg)
-        {
-            if (Message != null)
-                Message(this, msg);
-        }
-
-        private void readStandardOutput(Process p)
-        {
-            using (StreamReader sr = p.StandardOutput)
-            {
-                while (sr.BaseStream.CanRead)
-                {
-                    string test = sr.ReadLine();
-
-                    if (test == null)
-                        break;
-
-                    if (StandardOutputMessage != null)
-                    {
-                        StandardOutputMessage(this, test);
-                    }
-                }
-            }
-        }
-
-        private void readStandardError(Process p)
-        {
-            using (StreamReader sr = p.StandardError)
-            {
-                while (sr.BaseStream.CanRead)
-                {
-                    string test = sr.ReadLine();
-
-                    if (test == null)
-                        break;
-
-                    if (StandardErrorMessage != null)
-                    {
-                        StandardErrorMessage(this, test);
-                    }
-                }
-            }
-        }
-
         public void DownloadAndBuildQT_x64()
         {
             if (!Directory.Exists(destinationFolder))
 
             message("Finished buidling qt  - - - DONE");
 
-            if (Finished != null)
-            {
-                Finished(this);
-            }
+            OnFinished();
         }
 
         private void configureQT()
             p.WaitForExit();
             p.Close();
         }
-
     }
 }