update launch utils

This commit is contained in:
Tian Liao 2024-10-17 16:45:19 +08:00
commit 3e45a394ce
2 changed files with 25 additions and 18 deletions

View file

@ -73,17 +73,13 @@ namespace CalculatorApp
protected override void OnActivated(IActivatedEventArgs args) protected override void OnActivated(IActivatedEventArgs args)
{ {
if (args.Kind != ActivationKind.Protocol) return; if (args.Kind != ActivationKind.Protocol)
if (args.IsSnapshotProtocol())
{ {
var protoArgs = (IProtocolActivatedEventArgs)args; return;
OnAppLaunch(args, }
new SnapshotLaunchArguments else if (args.TryGetSnapshotProtocol(out var protoArgs))
{ {
Snapshot = null // TODO: OnAppLaunch(args, protoArgs.GetSnapshotLaunchArgs(), false);
},
false);
} }
else else
{ {

View file

@ -7,16 +7,27 @@ namespace CalculatorApp
{ {
internal class SnapshotLaunchArguments internal class SnapshotLaunchArguments
{ {
public ApplicationSnapshot Snapshot; public bool HasError { get; set; }
public ApplicationSnapshot Snapshot { get; set; }
} }
internal static class LaunchExtensions internal static class LaunchExtensions
{ {
public static bool IsSnapshotProtocol(this IActivatedEventArgs args) => public static bool TryGetSnapshotProtocol(this IActivatedEventArgs args, out IProtocolActivatedEventArgs result)
args is IProtocolActivatedEventArgs protoArgs && {
protoArgs.Uri != null && result = null;
protoArgs.Uri.Segments != null && var protoArgs = args as IProtocolActivatedEventArgs;
protoArgs.Uri.Segments.Length == 2 && if (protoArgs == null || protoArgs.Uri == null)
protoArgs.Uri.Segments[0] == "snapshot/"; {
return false;
}
result = protoArgs;
return true;
}
public static SnapshotLaunchArguments GetSnapshotLaunchArgs(this IProtocolActivatedEventArgs args)
{
return null;
}
} }
} }