private static async Task<AdnWebAuthenticationResult> AuthenticateAsyncTask( WebAuthenticationOptions options, Uri startUri, Uri endUri) { TaskCompletionSource<int> tcs = new TaskCompletionSource<int>(); WebAuthenticationStatus responseStatus = WebAuthenticationStatus.Success; string responseData = ""; Popup popUp = new Popup { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Width = 800, Height = Window.Current.Bounds.Height }; var webAuthView = new AdnWebAuthView { Width = Window.Current.Bounds.Width, Height = Window.Current.Bounds.Height }; webAuthView.CancelledEvent += (s, e) => { responseStatus = WebAuthenticationStatus.UserCancel; popUp.IsOpen = false; tcs.TrySetResult(1); }; webAuthView.UriChangedEvent += (s, e) => { if (e != null) { if (e.Uri.AbsoluteUri.StartsWith( endUri.AbsoluteUri, StringComparison.OrdinalIgnoreCase)) { responseStatus = WebAuthenticationStatus.Success; responseData = e.Uri.AbsoluteUri; popUp.IsOpen = false; tcs.TrySetResult(1); } } }; webAuthView.NavFailedEvent += (s, e) => { if (e.Uri.AbsoluteUri.StartsWith( endUri.AbsoluteUri, StringComparison.OrdinalIgnoreCase)) { responseStatus = WebAuthenticationStatus.Success; responseData = e.Uri.AbsoluteUri; } else { responseStatus = WebAuthenticationStatus.ErrorHttp; responseData = e.Uri.AbsoluteUri; } popUp.IsOpen = false; tcs.TrySetResult(1); }; popUp.Child = webAuthView; popUp.IsOpen = true; webAuthView.Navigate(startUri); await tcs.Task; return new AdnWebAuthenticationResult { ResponseStatus = responseStatus, ResponseData = responseData }; }
private static async Task <AdnWebAuthenticationResult> AuthenticateAsyncTask( WebAuthenticationOptions options, Uri startUri, Uri endUri) { TaskCompletionSource <int> tcs = new TaskCompletionSource <int>(); WebAuthenticationStatus responseStatus = WebAuthenticationStatus.Success; string responseData = ""; Popup popUp = new Popup { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Width = 800, Height = Window.Current.Bounds.Height }; var webAuthView = new AdnWebAuthView { Width = Window.Current.Bounds.Width, Height = Window.Current.Bounds.Height }; webAuthView.CancelledEvent += (s, e) => { responseStatus = WebAuthenticationStatus.UserCancel; popUp.IsOpen = false; tcs.TrySetResult(1); }; webAuthView.UriChangedEvent += (s, e) => { if (e != null) { if (e.Uri.AbsoluteUri.StartsWith( endUri.AbsoluteUri, StringComparison.OrdinalIgnoreCase)) { responseStatus = WebAuthenticationStatus.Success; responseData = e.Uri.AbsoluteUri; popUp.IsOpen = false; tcs.TrySetResult(1); } } }; webAuthView.NavFailedEvent += (s, e) => { if (e.Uri.AbsoluteUri.StartsWith( endUri.AbsoluteUri, StringComparison.OrdinalIgnoreCase)) { responseStatus = WebAuthenticationStatus.Success; responseData = e.Uri.AbsoluteUri; } else { responseStatus = WebAuthenticationStatus.ErrorHttp; responseData = e.Uri.AbsoluteUri; } popUp.IsOpen = false; tcs.TrySetResult(1); }; popUp.Child = webAuthView; popUp.IsOpen = true; webAuthView.Navigate(startUri); await tcs.Task; return(new AdnWebAuthenticationResult { ResponseStatus = responseStatus, ResponseData = responseData }); }