Exemple #1
0
        private Injector(bool showOutputInWindow)
        {
            // I don't like the UI as dependency to the dll, but then again this is a unit test dll so it should be OK
            // Should introduce UI separately (perhaps the UI itself is the parameter on the constructor, that's it!!)
            // like this
            // public Injector(UIObject debugWindow) -- next version :)


            InjectionHelper.Initialize(showOutputInWindow);
            CurrentStatus = InjectionHelper.Status.Uninitialized;
            var errorCountAllowed = 100; // TODO: need to fix threading to actaully wait on a callback

            InjectionHelper.Log("Initializing Injector.");

            try
            {
                Thread.Sleep(1500); // TODO: need to fix threading to actaully wait on a callback

                do
                {
                    CurrentStatus = InjectionHelper.GetStatus();
                    InjectionHelper.Log("Checking status.");
                    if (CurrentStatus.ToString().ToUpper().Contains("ERROR"))
                    {
                        Log(string.Format("Injector Initialization Error or Delay: {0} {1} Retries remaining ",
                                          new object[] { CurrentStatus.ToString(), errorCountAllowed }));
                        if (errorCountAllowed-- <= 0)
                        {
                            break;
                        }
                    }
                } while (CurrentStatus != InjectionHelper.Status.Ready);

                if (CurrentStatus == InjectionHelper.Status.Ready)
                {
                    IniALL.Ini();
                }
            }
            catch (Exception e)
            {
                InjectionHelper.Log("Error during Injector Intialization :" + e.Message);
            }
        }
 private void InitializationCompleted(InjectionHelper.Status status)
 {
     if (status == InjectionHelper.Status.Ready)
     {
         txtOutput.Text = @"Initialization is completed successfully, enjoy!";
         foreach (Control ctrl in this.Controls)
         {
             if (ctrl is Button)
             {
                 ctrl.Enabled = true;
             }
         }
         txtOutput.Enabled = true;
     }
     else
     {
         txtOutput.Text = string.Format(@"Initialization is failed with error [{0}]!", status.ToString());
     }
 }
Exemple #3
0
 private void InitializationCompleted(InjectionHelper.Status status)
 {
     if (status == InjectionHelper.Status.Ready)
     {
         Console.WriteLine(@"Initialization is completed successfully, enjoy!");
     }
     else
     {
         Console.WriteLine(string.Format(@"Initialization is failed with error [{0}]!", status.ToString()));
     }
 }