Update App.xaml.cs (#2230)

Implemented guard clause to improve readability of OnActivated
This commit is contained in:
philliprobinson 2024-09-27 17:40:36 +12:00 committed by GitHub
commit 6ece807db8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -73,25 +73,24 @@ namespace CalculatorApp
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.Protocol)
if (args.Kind != ActivationKind.Protocol) return;
if (args.IsSnapshotProtocol())
{
if (args.IsSnapshotProtocol())
{
var protoArgs = (IProtocolActivatedEventArgs)args;
OnAppLaunch(args,
new SnapshotLaunchArguments
{
ActivityId = protoArgs.Uri.GetActivityId(),
LaunchUri = protoArgs.Uri
},
false);
}
else
{
// handle any unknown protocol launch as a normal app launch.
OnAppLaunch(args, null, false);
}
var protoArgs = (IProtocolActivatedEventArgs)args;
OnAppLaunch(args,
new SnapshotLaunchArguments
{
ActivityId = protoArgs.Uri.GetActivityId(),
LaunchUri = protoArgs.Uri
},
false);
}
else
{
// handle any unknown protocol launch as a normal app launch.
OnAppLaunch(args, null, false);
}
}
private void OnAppLaunch(IActivatedEventArgs args, object arguments, bool isPreLaunch)