mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-20 13:23:13 -07:00
update launch utils
This commit is contained in:
parent
7258237c8a
commit
3e45a394ce
2 changed files with 25 additions and 18 deletions
|
@ -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
|
||||||
{
|
{
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue