diff options
Diffstat (limited to 'MediaBrowser.Server.Mac')
| -rw-r--r-- | MediaBrowser.Server.Mac/Main.cs | 20 | ||||
| -rw-r--r-- | MediaBrowser.Server.Mac/Native/BaseMonoApp.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Server.Mac/Native/NativeApp.cs | 22 |
3 files changed, 44 insertions, 4 deletions
diff --git a/MediaBrowser.Server.Mac/Main.cs b/MediaBrowser.Server.Mac/Main.cs index b4184f3b19..cffa62fae7 100644 --- a/MediaBrowser.Server.Mac/Main.cs +++ b/MediaBrowser.Server.Mac/Main.cs @@ -146,6 +146,26 @@ namespace MediaBrowser.Server.Mac MenuBarIcon.Instance.Terminate (); } + public static void Restart() + { + _logger.Info("Disposing app host"); + AppHost.Dispose(); + + _logger.Info("Starting new instance"); + + var currentProcess = Process.GetCurrentProcess(); + + var args = Environment.GetCommandLineArgs() + .Select(NormalizeCommandLineArgument); + + var commandLineArgsString = string.Join(" ", args.ToArray()); + + Process.Start(currentProcess.MainModule.FileName, commandLineArgsString); + + _logger.Info("AppController.Terminate"); + MenuBarIcon.Instance.Terminate(); + } + /// <summary> /// Handles the UnhandledException event of the CurrentDomain control. /// </summary> diff --git a/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs b/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs index 9821f49ddd..57610dfc2c 100644 --- a/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs +++ b/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs @@ -19,16 +19,16 @@ namespace MediaBrowser.Server.Mac /// <summary> /// Restarts this instance. /// </summary> - public void Restart() + public virtual void Restart() { - + throw new NotImplementedException(); } /// <summary> /// Determines whether this instance [can self restart]. /// </summary> /// <returns><c>true</c> if this instance [can self restart]; otherwise, <c>false</c>.</returns> - public bool CanSelfRestart + public virtual bool CanSelfRestart { get { diff --git a/MediaBrowser.Server.Mac/Native/NativeApp.cs b/MediaBrowser.Server.Mac/Native/NativeApp.cs index f7c2dd4c95..4515be0517 100644 --- a/MediaBrowser.Server.Mac/Native/NativeApp.cs +++ b/MediaBrowser.Server.Mac/Native/NativeApp.cs @@ -13,7 +13,27 @@ namespace MediaBrowser.Server.Mac public override void Shutdown() { MainClass.Shutdown(); - } + } + + /// <summary> + /// Determines whether this instance [can self restart]. + /// </summary> + /// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value> + public override bool CanSelfRestart + { + get + { + return true; + } + } + + /// <summary> + /// Restarts this instance. + /// </summary> + public override void Restart() + { + MainClass.Restart(); + } } } |
