From 1189ce9086730a77d098c6f70ce0f31247a8c4f6 Mon Sep 17 00:00:00 2001 From: philliprobinson <52636400+philliprobinson@users.noreply.github.com> Date: Tue, 10 Sep 2024 10:47:40 +1200 Subject: [PATCH] Update App.xaml.cs Implemented guard clause to improve readability of OnActivated --- src/Calculator/App.xaml.cs | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/Calculator/App.xaml.cs b/src/Calculator/App.xaml.cs index 78849c76..342e6851 100644 --- a/src/Calculator/App.xaml.cs +++ b/src/Calculator/App.xaml.cs @@ -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)