Skip to content

Commit 6ece807

Browse files
Update App.xaml.cs (#2230)
Implemented guard clause to improve readability of OnActivated
1 parent 0465094 commit 6ece807

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

src/Calculator/App.xaml.cs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,24 @@ protected override void OnLaunched(LaunchActivatedEventArgs args)
7373

7474
protected override void OnActivated(IActivatedEventArgs args)
7575
{
76-
if (args.Kind == ActivationKind.Protocol)
76+
if (args.Kind != ActivationKind.Protocol) return;
77+
78+
if (args.IsSnapshotProtocol())
7779
{
78-
if (args.IsSnapshotProtocol())
79-
{
80-
var protoArgs = (IProtocolActivatedEventArgs)args;
81-
OnAppLaunch(args,
82-
new SnapshotLaunchArguments
83-
{
84-
ActivityId = protoArgs.Uri.GetActivityId(),
85-
LaunchUri = protoArgs.Uri
86-
},
87-
false);
88-
}
89-
else
90-
{
91-
// handle any unknown protocol launch as a normal app launch.
92-
OnAppLaunch(args, null, false);
93-
}
80+
var protoArgs = (IProtocolActivatedEventArgs)args;
81+
OnAppLaunch(args,
82+
new SnapshotLaunchArguments
83+
{
84+
ActivityId = protoArgs.Uri.GetActivityId(),
85+
LaunchUri = protoArgs.Uri
86+
},
87+
false);
9488
}
89+
else
90+
{
91+
// handle any unknown protocol launch as a normal app launch.
92+
OnAppLaunch(args, null, false);
93+
}
9594
}
9695

9796
private void OnAppLaunch(IActivatedEventArgs args, object arguments, bool isPreLaunch)

0 commit comments

Comments
 (0)