Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Remove old overload of HandleEvents
Browse files Browse the repository at this point in the history
  • Loading branch information
caesay committed Mar 19, 2022
1 parent 8f6eaf8 commit aa945cd
Showing 1 changed file with 0 additions and 44 deletions.
44 changes: 0 additions & 44 deletions src/Squirrel/SquirrelAwareApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,50 +28,6 @@ namespace Squirrel
#endif
public static class SquirrelAwareApp
{
/// <summary>
/// This overload is obsolete and will be removed in a future version.
/// See <see cref="HandleEvents(SquirrelHook, SquirrelHook, SquirrelHook, SquirrelHook, SquirrelRunHook, string[])" />
/// </summary>
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[Obsolete("Use the HandleEvents overload which provides a SemanticVersion as the argument")]
public static void HandleEvents(
Action<Version> onInitialInstall = null,
Action<Version> onAppUpdate = null,
Action<Version> onAppObsoleted = null,
Action<Version> onAppUninstall = null,
Action onFirstRun = null,
string[] arguments = null)
{
Action<Version> defaultBlock = (v => { });
var args = arguments ?? Environment.GetCommandLineArgs().Skip(1).ToArray();
if (args.Length == 0) return;

var lookup = new[] {
new { Key = "--squirrel-install", Value = onInitialInstall ?? defaultBlock },
new { Key = "--squirrel-updated", Value = onAppUpdate ?? defaultBlock },
new { Key = "--squirrel-obsolete", Value = onAppObsoleted ?? defaultBlock },
new { Key = "--squirrel-uninstall", Value = onAppUninstall ?? defaultBlock },
}.ToDictionary(k => k.Key, v => v.Value);

if (args[0] == "--squirrel-firstrun") {
(onFirstRun ?? (() => { }))();
return;
}

if (args.Length != 2) return;

if (!lookup.ContainsKey(args[0])) return;
var version = new SemanticVersion(args[1]).Version;

try {
lookup[args[0]](version);
if (!ModeDetector.InUnitTestRunner()) Environment.Exit(0);
} catch (Exception ex) {
LogHost.Default.ErrorException("Failed to handle Squirrel events", ex);
if (!ModeDetector.InUnitTestRunner()) Environment.Exit(-1);
}
}

/// <summary>
/// Call this method as early as possible in app startup. This method
/// will dispatch to your methods to set up your app. Depending on the
Expand Down

0 comments on commit aa945cd

Please sign in to comment.