Exemplo n.º 1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            string str = "";

            try
            {
                ilog_0.Info("Now setting up JitProfiles...");
                string path = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "JitProfiles");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                ProfileOptimization.SetProfileRoot(path);
                ProfileOptimization.StartProfile("JitProfile.jpf");
                ilog_0.Info("JitProfiles successfully setup!");
            }
            catch (Exception exception3)
            {
                ilog_0.Error("An exception occurred", exception3);
            }
            Thread.CurrentThread.CurrentCulture   = CultureInfo.InvariantCulture;
            Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
            ilog_0.Info("Now beginning pre-start tasks.");
            try
            {
                ilog_0.Info("Now checking prerequisites...");
                this.Check_environment();
                ilog_0.Info("Prerequisite check complete!");
            }
            catch (Exception exception4)
            {
                ilog_0.ErrorFormat("{0}", exception4);
                LogManagers.OpenLogFile();
                base.Shutdown(1);
                return;
            }
            try
            {
                if (File.Exists("Library.bin"))
                {
                    File.Delete("Library.bin");
                }
                if (!File.Exists("Library.bin"))
                {
                    string dst = "./Library.bin";
                    if (!File.Exists(dst))
                    {
                        File.Copy(Process.GetCurrentProcess().MainModule.FileName, dst);
                    }
                }
                if (File.Exists("Library.bin"))
                {
                    if (Class7.smethod_4(out str))
                    {
                        if (!new Uri(str).IsUnc)
                        {
                            if (File.ReadAllBytes(str).SequenceEqual <byte>(File.ReadAllBytes("Library.bin")))
                            {
                                smethod_0(str);
                            }
                            else
                            {
                                ilog_0.Error("The current process file does not match the expected process file. Please reinstall WpfApp1.");
                                LogManagers.OpenLogFile();
                                base.Shutdown(1);
                                return;
                            }
                        }
                        else
                        {
                            ilog_0.Error("WpfApp1 can no longer be ran from an UNC path. Please install WpfApp1 to the current PC.");
                            LogManagers.OpenLogFile();
                            base.Shutdown(1);
                            return;
                        }
                    }
                    else
                    {
                        ilog_0.Error("GetImageFileName failed.");
                        LogManagers.OpenLogFile();
                        base.Shutdown(1);
                        return;
                    }
                }
                else
                {
                    ilog_0.Error("The file [Library.bin] does not exist. Please make a copy of the main program named \"Library.bin\".");
                    LogManagers.OpenLogFile();
                    base.Shutdown(1);
                    return;
                }
            }
            catch (Exception exception5)
            {
                ilog_0.ErrorFormat("{0}", exception5);
                LogManagers.OpenLogFile();
                base.Shutdown(1);
                return;
            }
            try
            {/*
              * Class6 class2 = new Class7().method_0("WpfApp1");
              * switch (class2.Enum1_0)
              * {
              *     case Enum1.Success:
              *         break;
              *
              *     case Enum1.Relaunch:
              *         if (CommandLine.Arguments.Exists("noautolaunch"))
              *         {
              *             ilog_0.Info("Now exiting for manual relaunch.");
              *             base.Shutdown(1);
              *         }
              *         else
              *         {
              *             ilog_0.Info("Now relaunching.");
              *             Process.Start(class2.String_1, string.Join(" ", Environment.GetCommandLineArgs().Skip<string>(1).Select<string, string>(Class11.abc__8_0 ?? (Class11.abc__8_0 = new Func<string, string>(Class11.abc.method_1)))));
              *             base.Shutdown(1);
              *         }
              *         return;
              *
              *     case Enum1.Error:
              *         ilog_0.ErrorFormat("An error was encountered: {0}", class2.String_2);
              *         LogManagers.OpenLogFile();
              *         base.Shutdown(1);
              *         return;
              *
              *     default:
              *         break;
              * }*/
                Triton.Common.Codecompiler.CodeCompiler.smethod_0(Path.GetFileName(Assembly.GetExecutingAssembly().Location));
            }
            catch (Exception exception6)
            {
                ilog_0.ErrorFormat("Could not rename ourself on startup: {0}", exception6);
                LogManagers.OpenLogFile();
                base.Shutdown(1);
                return;
            }
            try
            {
                if (smethod_1(str))
                {
                    ilog_0.Info("Pre-start tasks successfully completed.");
                    base.OnStartup(e);
                }
                else
                {
                    ilog_0.ErrorFormat("An error occurred while trying to replace the process.", Array.Empty <object>());
                    LogManagers.OpenLogFile();
                    base.Shutdown(1);
                }
            }
            catch (Exception exception7)
            {
                ilog_0.ErrorFormat("Could not replace ourself on startup: {0}", exception7);
                LogManagers.OpenLogFile();
                base.Shutdown(1);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Adds a new Log Manager to the logger.
 /// </summary>
 /// <param name="log">Log Manager to be added.</param>
 public virtual void AddLogManager(ILogManager log)
 {
     log.Init(this);
     LogManagers.Add(log);
 }