예제 #1
0
 public static async Task <bool> LaunchProtocolAsync(NotepadsOperationProtocol operation)
 {
     try
     {
         if (operation == NotepadsOperationProtocol.Unrecognized)
         {
             return(false);
         }
         else if (operation == NotepadsOperationProtocol.OpenNewInstance)
         {
             var uriToLaunch   = $"notepads://{NewInstanceProtocolStr}";
             var launchOptions = new LauncherOptions {
                 TargetApplicationPackageFamilyName = Package.Current.Id.FamilyName
             };
             return(await Launcher.LaunchUriAsync(new Uri(uriToLaunch.ToLower()), launchOptions));
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         LoggingService.LogError($"[{nameof(NotepadsProtocolService)}] Failed to execute protocol: {operation}, Exception: {ex}");
         Analytics.TrackEvent("NotepadsProtocolService_FailedToExecuteProtocol", new Dictionary <string, string>()
         {
             { "Protocol", operation.ToString() },
             { "Exception", ex.Message }
         });
         return(false);
     }
 }
예제 #2
0
 public static async Task <bool> LaunchProtocolAsync(NotepadsOperationProtocol operation)
 {
     try
     {
         if (operation == NotepadsOperationProtocol.Unrecognized)
         {
             return(false);
         }
         else if (operation == NotepadsOperationProtocol.OpenNewInstance)
         {
             var uriToLaunch = $"notepads://{NewInstanceProtocolStr}";
             return(await Windows.System.Launcher.LaunchUriAsync(new Uri(uriToLaunch.ToLower())));
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         LoggingService.LogError($"[NotepadsProtocolService] Failed to execute protocol: {operation.ToString()}, Exception: {ex}");
         Analytics.TrackEvent("NotepadsProtocolService_FailedToExecuteProtocol", new Dictionary <string, string>()
         {
             { "Protocol", operation.ToString() },
             { "Exception", ex.Message }
         });
         return(false);
     }
 }