示例#1
0
 private bool TryGetCode(string query, out string code)
 {
     var decoder = new WwwFormUrlDecoder(query);
     var entry = decoder.FirstOrDefault(e => e.Name == "code");
     code = entry?.Value;
     return entry != null;
 }
示例#2
0
        public static void ParseArguments(string arguments)
        {
            if (string.IsNullOrEmpty(arguments))
            {
                return;
            }
            var decoder = new WwwFormUrlDecoder(arguments);

            var city = decoder.FirstOrDefault(x => x.Name.Equals("city"));
            var parkingLot = decoder.FirstOrDefault(x => x.Name.Equals("parkingLot"));
            if (city != null && parkingLot != null)
            {
                Task.Run(async () =>
                {
                    await ServiceLocator.Current.GetInstance<MainViewModel>().TrySelectParkingLotById(city.Value, parkingLot.Value);
                });
            }else if (city != null)
            {
                Task.Run(async () =>
                {
                    await ServiceLocator.Current.GetInstance<MainViewModel>().TrySelectCityById(city.Value);
                });
            }
        }
示例#3
0
 private void TopicWebView_OnNavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
 {
     if (args.Uri != null && args.Uri.AbsoluteUri.StartsWith(Strings.LocalUriPrefix))
     {
         args.Cancel = true;
         if (args.Uri.AbsoluteUri.Contains("quote"))
         {
             var decoder = new WwwFormUrlDecoder(args.Uri.Query);
             var postId = decoder.FirstOrDefault(x => x.Name == "postId")?.Value;
             if (!string.IsNullOrEmpty(postId))
                 Loc.Topic.ShowEditorCommand.Execute(Loc.Topic.CurrentTopic.TopicNewPostUriForm + $"&numrep={postId}");
         }
         else
         {
             Debug.WriteLine("WW " + args.Uri.Query + "-- " + args.Uri + " -- " + args.Uri.AbsoluteUri);
             string param = args.Uri.Query.Replace("?", "");
             if (Loc.Main.ContextMessageCommand.CanExecute(param))
                 Loc.Main.ContextMessageCommand.Execute(param);
         }
     }
 }
示例#4
0
 /// <summary>
 /// Handles <see cref="WebView.NavigationCompleted"/> event, to determine if Sign-in/Sign-out
 /// process was successfull.
 /// </summary>
 /// <param name="args">The event data</param>
 /// <returns><see cref="MSHealthNavigationResult"/> of Sign-in/Sign-out process.</returns>
 public async Task<MSHealthNavigationResult> HandleNavigationCompleted(WebViewNavigationCompletedEventArgs args)
 {
     MSHealthNavigationResult loResult = MSHealthNavigationResult.None;
     // Check if URL has Authentication path
     if (args.Uri.LocalPath.StartsWith(AUTH_PATH, StringComparison.OrdinalIgnoreCase))
     {
         WwwFormUrlDecoder loDecoder = new WwwFormUrlDecoder(args.Uri.Query);
         // Read Authentication Code
         IWwwFormUrlDecoderEntry loCode = loDecoder.FirstOrDefault((entry) => entry.Name.Equals("code", StringComparison.OrdinalIgnoreCase));
         // Read Authentication Errors
         IWwwFormUrlDecoderEntry loError = loDecoder.FirstOrDefault((entry) => entry.Name.Equals("error", StringComparison.OrdinalIgnoreCase));
         IWwwFormUrlDecoderEntry loErrorDesc = loDecoder.FirstOrDefault((entry) => entry.Name.Equals("error_description", StringComparison.OrdinalIgnoreCase));
         // Check the code to see if this is sign-in or sign-out
         if (loCode != null)
         {
             // Check error and throw Exception
             if (loError != null)
                 throw new Exception(string.Format("{0}\r\n{1}", loError.Value, loErrorDesc.Value));
             // Get Token
             try
             {
                 // Signed-in
                 Token = await GetToken(loCode.Value, false);
                 IsSignedIn = true;
                 loResult = MSHealthNavigationResult.SignIn;
             }
             catch
             {
                 // Error
                 Token = null;
                 IsSignedIn = false;
                 loResult = MSHealthNavigationResult.Error;
                 throw;
             }
         }
         else
         {
             // Signed-out
             Token = null;
             IsSignedIn = false;
             loResult = MSHealthNavigationResult.SignOut;
         }
     }
     return loResult;
 }