protected override void NavigateToCore(string uri, NavigationOptions options) { if (uri == null) { throw new ArgumentNullException(nameof(uri)); } _ = PerformNavigationAsync(); async Task PerformNavigationAsync() { try { var shouldContinueNavigation = await NotifyLocationChangingAsync(uri, options.HistoryEntryState, false); if (!shouldContinueNavigation) { Log.NavigationCanceled(_logger, uri); return; } DefaultWebAssemblyJSRuntime.Instance.InvokeVoid(Interop.NavigateTo, uri, options); } catch (Exception ex) { // We shouldn't ever reach this since exceptions thrown from handlers are handled in HandleLocationChangingHandlerException. // But if some other exception gets thrown, we still want to know about it. Log.NavigationFailed(_logger, uri, ex); } } }
public bool TryNavigateToSymbol(ISymbol symbol, Project project, NavigationOptions options, CancellationToken cancellationToken) { if (project == null || symbol == null) { return(false); } symbol = symbol.OriginalDefinition; // Prefer visible source locations if possible. var sourceLocations = symbol.Locations.Where(loc => loc.IsInSource); var visibleSourceLocations = sourceLocations.Where(loc => loc.IsVisibleSourceLocation()); var sourceLocation = visibleSourceLocations.FirstOrDefault() ?? sourceLocations.FirstOrDefault(); if (sourceLocation != null) { var targetDocument = project.Solution.GetDocument(sourceLocation.SourceTree); if (targetDocument != null) { var editorWorkspace = targetDocument.Project.Solution.Workspace; var navigationService = editorWorkspace.Services.GetRequiredService <IDocumentNavigationService>(); return(navigationService.TryNavigateToSpan(editorWorkspace, targetDocument.Id, sourceLocation.SourceSpan, options, cancellationToken)); } } // We don't have a source document, so show the Metadata as Source view in a preview tab. if (!_metadataAsSourceFileService.IsNavigableMetadataSymbol(symbol)) { return(false); } // Should we prefer navigating to the Object Browser over metadata-as-source? if (_globalOptions.GetOption(VisualStudioNavigationOptions.NavigateToObjectBrowser, project.Language)) { var libraryService = project.LanguageServices.GetService <ILibraryService>(); if (libraryService == null) { return(false); } var compilation = project.GetCompilationAsync(cancellationToken).WaitAndGetResult(cancellationToken); var navInfo = libraryService.NavInfoFactory.CreateForSymbol(symbol, project, compilation); if (navInfo == null) { navInfo = libraryService.NavInfoFactory.CreateForProject(project); } if (navInfo != null) { var navigationTool = IServiceProviderExtensions.GetService <SVsObjBrowser, IVsNavigationTool>(_serviceProvider); return(navigationTool.NavigateToNavInfo(navInfo) == VSConstants.S_OK); } // Note: we'll fallback to Metadata-As-Source if we fail to get IVsNavInfo, but that should never happen. } // Generate new source or retrieve existing source for the symbol in question return(ThreadingContext.JoinableTaskFactory.Run(() => TryNavigateToMetadataAsync(project, symbol, options, cancellationToken))); }
public static async Task <bool> Login(string accountName, string password, Page page) { //page.EmulateAsync(DeviceDescriptors.Get(DeviceDescriptorName.IPhone6); try { await page.TypeAsync("input[name=Login]", accountName, _typeOptions); await page.WaitForTimeoutAsync(500); await ClickSubmit(page); await page.WaitForTimeoutAsync(500); await page.TypeAsync("input[name=Password]", password, _typeOptions); await ClickSubmit(page); var navigationOptions = new NavigationOptions { WaitUntil = new[] { WaitUntilNavigation.DOMContentLoaded } }; await page.WaitForNavigationAsync(navigationOptions); } catch (Exception exception) { Log.Error(exception); return(false); } return(true); }
public async Task LoadAsync(string uri, Options options) { _app.DebugApp("Load page {0}", uri); _loadURI = uri; _options = options; await InitializeInterception(); _app.DebugApp("Navigating the page to {0}", _loadURI); var navigationOptions = new NavigationOptions() { Timeout = 0, WaitUntil = new WaitUntilNavigation[] { WaitUntilNavigation.DOMContentLoaded } }; if (_loadURI.StartsWith("http://") || _loadURI.StartsWith("https://")) { await _page.GoToAsync(_loadURI, navigationOptions); } else { await _page.GoToAsync("https://domain/" + _loadURI, navigationOptions); } // Available in Chrome M73+. try { await _session.SendAsync("Page.resetNavigationHistory"); } catch { } }
protected override void NavigateToCore(string uri, NavigationOptions options) { Log.RequestingNavigation(_logger, uri, options); if (_jsRuntime == null) { var absoluteUriString = ToAbsoluteUri(uri).ToString(); throw new NavigationException(absoluteUriString); } _ = PerformNavigationAsync(); async Task PerformNavigationAsync() { try { var shouldContinueNavigation = await NotifyLocationChangingAsync(uri, options.HistoryEntryState, false); if (!shouldContinueNavigation) { Log.NavigationCanceled(_logger, uri); return; } await _jsRuntime.InvokeVoidAsync(Interop.NavigateTo, uri, options); } catch (Exception ex) { // We shouldn't ever reach this since exceptions thrown from handlers are handled in HandleLocationChangingHandlerException. // But if some other exception gets thrown, we still want to know about it. Log.NavigationFailed(_logger, uri, ex); UnhandledException?.Invoke(this, ex); } } }
public async Task NavigateToAsync(NavigationOptions options, CancellationToken cancellationToken) { var location = await DefinitionBucket.DefinitionItem.GetNavigableLocationAsync( Presenter._workspace, cancellationToken).ConfigureAwait(false); await location.TryNavigateToAsync(_threadingContext, options, cancellationToken).ConfigureAwait(false); }
public async Task <bool> TryNavigateToAsync(Workspace workspace, NavigationOptions options, CancellationToken cancellationToken) { var location = await GetNavigableLocationAsync(workspace, cancellationToken).ConfigureAwait(false); return(location != null && await location.NavigateToAsync(options, cancellationToken).ConfigureAwait(false)); }
public static async Task <bool> Login(string accountName, string password, Page page) { try { await page.TypeAsync("input[name=login]", accountName); await page.WaitForTimeoutAsync(500); await page.ClickAsync("button[type=submit]"); //await page.WaitForNavigationAsync(); await page.WaitForTimeoutAsync(500); await page.TypeAsync("input[type=password]", password); await page.ClickAsync("button[type=submit]"); var navigationOptions = new NavigationOptions { WaitUntil = new[] { WaitUntilNavigation.DOMContentLoaded } }; await page.WaitForNavigationAsync(navigationOptions); } catch (Exception exception) { Log.Error(exception); return(false); } return(true); }
protected override void NavigateToCore(string uri, NavigationOptions options) { _ = PerformNavigationAsync(); async Task PerformNavigationAsync() { try { var shouldContinueNavigation = await NotifyLocationChangingAsync(uri, options.HistoryEntryState, false); if (!shouldContinueNavigation) { Log.NavigationCanceled(_logger, uri); return; } _ipcSender.Navigate(uri, options); } catch (Exception ex) { // We shouldn't ever reach this since exceptions thrown from handlers are handled in HandleLocationChangingHandlerException. // But if some other exception gets thrown, we still want to know about it. Log.NavigationFailed(_logger, uri, ex); _ipcSender.NotifyUnhandledException(ex); } } }
public async Task <ActionResult> Buscando(String id) { var cepModel = new CepModel(); await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision); Browser browser = await Puppeteer.LaunchAsync(new LaunchOptions { //Não mostrar: Headless = true //Mostrar: //Headless = false }); //Url Correios string fullUrl = "http://www.buscacep.correios.com.br/sistemas/buscacep/BuscaCepEndereco.cfm"; //Abertura de pagina var page = await browser.NewPageAsync(); var timeout = (int)TimeSpan.FromSeconds(30).TotalMilliseconds; page.DefaultNavigationTimeout = timeout; page.DefaultTimeout = timeout; var options = new NavigationOptions { Timeout = timeout }; await page.GoToAsync(fullUrl, options); //Preenchimento e clique await page.TypeAsync("[name='relaxation']", id); await page.ClickAsync("[value='Buscar']"); try { //Obter dados var _obterDados = new ObterDados(); var _logradouro = _obterDados.GetLogradouro(page); cepModel.logradouro = await _logradouro; var _bairro = _obterDados.GetBairro(page); cepModel.bairro = await _bairro; var _estado = _obterDados.GetEstado(page); cepModel.estado = await _estado; await browser.CloseAsync(); cepModel.cep = id; //Fim Obter dados } catch { Invalido(); } return(View(cepModel)); }
public static IServiceCollection AddNavigation <TNavigationItem>(this IServiceCollection services, INavigationProvider <TNavigationItem> provider, Action <IServiceProvider, NavigationOptions <TNavigationItem> > configure) where TNavigationItem : NavigationItem <TNavigationItem>, new() { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (provider == null) { throw new ArgumentNullException(nameof(provider)); } services.AddMemoryCache(); services.TryAddSingleton <INavigationCache, NavigationCache>(); services.TryAddScoped(typeof(INavigationProvider <TNavigationItem>), serviceProvider => provider); services.TryAddScoped(typeof(NavigationOptions <TNavigationItem>), serviceProvider => { var options = new NavigationOptions <TNavigationItem>(); configure?.Invoke(serviceProvider, options); return(options); }); services.TryAddScoped(typeof(INavigationBuilder <>), typeof(NavigationBuilder <>)); services.TryAddScoped(typeof(INavigation <>), typeof(Navigation <>)); services.TryAddScoped(typeof(IBreadcrumbNavigation <>), typeof(BreadcrumbNavigation <>)); return(services); }
private void MakeRoot <TViewModel>(NavigationOptions options) where TViewModel : ViewModel { if (this.currentController != null) { if (this.currentController.PresentingViewController != null) { this.currentController.PresentingViewController.DismissViewController(false, null); } if (this.currentController.NavigationController != null) { this.currentController.NavigationController.PopToRootViewController(false); } } UIViewController viewControllerToMakeRoot = this.viewControllerFactory.InstantiateViewController <TViewModel>(options.Parameter); UIWindow window = UIApplication.SharedApplication.KeyWindow; window.RootViewController = viewControllerToMakeRoot.NavigationController == null ? new UINavigationController(viewControllerToMakeRoot) : viewControllerToMakeRoot; UIView.Transition( window, Constants.TransitionDuration, UIViewAnimationOptions.TransitionCrossDissolve, () => { }, () => { }); }
/// <summary> /// Navigates to a view specified by the view model type. /// </summary> /// <param name="options">Additional options for the navigation request.</param> public void NavigateTo <TViewModel>(NavigationOptions options) where TViewModel : ViewModel { if (options.PresentationType == PresentationType.ModalWithNavigation || options.PresentationType == PresentationType.ModalWithNavigationFullScreen) { this.PresentWithNavigation <TViewModel>( options, options.PresentationType == PresentationType.ModalWithNavigationFullScreen); } else if (options.PresentationType == PresentationType.Root) { // TODO: signal complete this.MakeRoot <TViewModel>(options); } else if (options.PresentationType == PresentationType.Standard) { // TODO: signal complete this.Push <TViewModel>(options); } else { throw new ArgumentException("Unknown PresentationType (" + options.PresentationType + ")."); } }
private static void NavigateToFiles( ISolution solution, List <FileGeneratorOutput> fileGeneratorOutputs, List <InPlaceGeneratorOutput> inPlaceGeneratorOutputs) { NavigationManager navigationManager = NavigationManager.GetInstance(solution); var navigationOptions = NavigationOptions.FromWindowContext( Shell.Instance.GetComponent <IMainWindowPopupWindowContext>().Source, "", false /* activate */ ); foreach (FileGeneratorOutput output in fileGeneratorOutputs) { var navigationPoint = new ProjectFileNavigationPoint(output.GeneratedProjectFile); navigationManager.Navigate(navigationPoint, navigationOptions); } foreach (InPlaceGeneratorOutput output in inPlaceGeneratorOutputs) { var navigationPoint = new ProjectFileNavigationPoint(output.ProjectFile); navigationManager.Navigate(navigationPoint, navigationOptions); } }
/// <summary> /// TODO: Figure out why Creatinig PDF does not work in production. /// </summary> /// <param name="file"></param> static async Task createPDF(string file) { try { await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision); var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true }); var page = await browser.NewPageAsync(); await page.SetViewportAsync(new ViewPortOptions { Width = 50000, Height = 50 }); NavigationOptions navOpts = new NavigationOptions(); navOpts.Timeout = 0; await page.GoToAsync(file, navOpts); PdfOptions options = new PdfOptions(); options.Width = 2000; options.Height = 1200; options.MarginOptions.Left = "100"; options.MarginOptions.Right = "100"; options.MarginOptions.Top = "50"; options.MarginOptions.Bottom = "50"; await page.PdfAsync(Path.Combine(Path.GetDirectoryName(location), Path.GetFileNameWithoutExtension(file) + ".pdf"), options); } catch (Exception e) { Debug.WriteLine(e.Message); } }
public void WaitNetworks() { NavigationOptions n = new NavigationOptions(); n.WaitUntil = new WaitUntilNavigation[] { WaitUntilNavigation.Networkidle2 }; page.WaitForNavigationAsync(n).Wait(); }
public async Task <List <string> > RunScenario(string[] queries, int pageCount) { var result = new List <string>(); try { var navigationOptions = new NavigationOptions { Timeout = 60000 }; using (var browser = await PuppeteerBrowser.GetBrowser(_chromiumSettings.GetPath(), _chromiumSettings.GetHeadless(), _chromiumSettings.GetArgs())) using (var page = await browser.NewPageAsync()) { await PuppeteerBrowser.Authenticate(page, _chromiumSettings.Proxy); var linkCount = 1; foreach (var query in queries) { await page.GoToAsync($"https://yandex.ru", navigationOptions); await page.TypeAsync("input", query, new TypeOptions { Delay = 150 }); await page.Keyboard.PressAsync($"{nameof(Key.Enter)}"); await page.WaitForNavigationAsync(navigationOptions); var contentSelector = "div.organic>h2>a"; for (int pageIndex = 0; pageIndex < pageCount; pageIndex++) { var links = await page.QuerySelectorAllAsync(contentSelector); foreach (var item in links) { var text = (await(await item.GetPropertyAsync("href")).JsonValueAsync()).ToString(); if (text.Contains("http") && !text.Contains("yabs.yandex")) { Report($"------------{linkCount}------------------------------------------------"); Report($"{text}"); result.Add(text); linkCount++; } } if (pageIndex < pageCount - 1) { await page.ClickAsync("div.pager a:last-child"); await page.WaitForNavigationAsync(navigationOptions); } } } } } catch (Exception exception) { Error(exception.ToString()); } return(result); }
protected override void NavigateToCore(string uri, NavigationOptions options) { if (uri == null) { throw new ArgumentNullException(nameof(uri)); } DefaultWebAssemblyJSRuntime.Instance.InvokeVoid(Interop.NavigateTo, uri, options); }
private static bool TryNavigateToSpan(Document document, int position, CancellationToken cancellationToken) { var solution = document.Project.Solution; var workspace = solution.Workspace; var service = workspace.Services.GetRequiredService <IDocumentNavigationService>(); var options = new NavigationOptions(PreferProvisionalTab: true, ActivateTab: true); return(service.TryNavigateToPosition(workspace, document.Id, position, virtualSpace: 0, options, cancellationToken)); }
private bool TryNavigateToSpan(Document document, int position, CancellationToken cancellationToken) { var solution = document.Project.Solution; var workspace = solution.Workspace; var service = workspace.Services.GetRequiredService <IDocumentNavigationService>(); var options = new NavigationOptions(PreferProvisionalTab: true, ActivateTab: true); return(_threadingContext.JoinableTaskFactory.Run(() => service.TryNavigateToPositionAsync(workspace, document.Id, position, virtualSpace: 0, options, cancellationToken))); }
private static void NavigateToFile(ISolution solution, IProjectFile generatedFile) { var navigationManager = NavigationManager.GetInstance(solution); var navigationPoint = new ProjectFileNavigationPoint(generatedFile); var navigationOptions = NavigationOptions.FromWindowContext( Shell.Instance.GetComponent <IMainWindowPopupWindowContext>().Source, "", false /* activate */ ); navigationManager.Navigate(navigationPoint, navigationOptions); }
protected override void NavigateToCore(string uri, NavigationOptions options) { Log.RequestingNavigation(_logger, uri, options); if (_jsRuntime == null) { var absoluteUriString = ToAbsoluteUri(uri).ToString(); throw new NavigationException(absoluteUriString); } _jsRuntime.InvokeVoidAsync(Interop.NavigateTo, uri, options).Preserve(); }
public override void SuccessfulFinish(IProgressIndicator pi) { if (DataModel.FilesToConvert.Length == 1) { var target = new ProjectFileNavigationPoint(DataModel.FilesToConvert[0].ConvertedFile); NavigationManager .GetInstance(Solution) .Navigate(target, NavigationOptions.FromWindowContext(mainWindowPopupWindowContext.Source, "")); } base.SuccessfulFinish(pi); }
public void NavigateTo() { var solution = _workspace.CurrentSolution; var document = solution.GetDocument(_documentId); if (document != null) { var navigator = _workspace.Services.GetService <IDocumentNavigationService>(); var options = new NavigationOptions(PreferProvisionalTab: true, ActivateTab: false); // TODO: Get the platform to use and pass us an operation context, or create one ourselves. navigator.TryNavigateToSpan(_workspace, document.Id, _span, options, CancellationToken.None); } }
static PupeeteerTool() { ops = new NavigationOptions() { Timeout = 120000, }; options = new LaunchOptions { Headless = true, /// pipe options is missing, may be in version 1.1.0 }; }
public virtual void NavigateTo() { var navigationService = Workspace.Services.GetService <IDocumentNavigationService>(); if (navigationService is null) { return; } // While navigating do not activate the tab, which will change focus from the tool window var options = new NavigationOptions(PreferProvisionalTab: true, ActivateTab: false); navigationService.TryNavigateToLineAndOffset(Workspace, DocumentId, LineSpan.Start, 0, options, ThreadingContext.DisposalToken); }
async static Task ProcessNavigateAsync( ISupportsNavigation supportsNavigation, TableEntryNavigateEventArgs e, IAsynchronousOperationListener listener, IUIThreadOperationExecutor operationExecutor) { using var token = listener.BeginAsyncOperation(nameof(ProcessNavigateAsync)); using var context = operationExecutor.BeginExecute( ServicesVSResources.IntelliSense, EditorFeaturesResources.Navigating, allowCancellation: true, showProgress: false); var options = new NavigationOptions(PreferProvisionalTab: e.IsPreview, ActivateTab: e.ShouldActivate); await supportsNavigation.NavigateToAsync(options, context.UserCancellationToken).ConfigureAwait(false); }
public static NavigationServiceBuilder AddProvider <TNavigationItem>(this NavigationServiceBuilder builder, INavigationProvider <TNavigationItem> provider, Action <IServiceProvider, NavigationOptions <TNavigationItem> > configure) where TNavigationItem : NavigationItem <TNavigationItem>, new() { builder.Services.TryAddScoped(typeof(INavigationProvider <TNavigationItem>), serviceProvider => provider); builder.Services.TryAddScoped(typeof(NavigationOptions <TNavigationItem>), serviceProvider => { var options = new NavigationOptions <TNavigationItem>(); configure?.Invoke(serviceProvider, options); return(options); }); return(builder); }
private void PresentWithNavigation <TViewModel>(NavigationOptions options, bool hideNavigationBar) where TViewModel : ViewModel { this.EnsureCurrentController(); UIViewController viewControllerToPresent = this.viewControllerFactory.InstantiateViewController <TViewModel>(options.Parameter); UINavigationController navigationController = new UINavigationController(viewControllerToPresent); if (hideNavigationBar) { navigationController.NavigationBar.Hidden = true; } this.currentController.PresentViewController(navigationController, options.AnimateTransitionToNextView, options.SignalNavigationComplete); }
protected bool TryNavigateToItem(int index, NavigationOptions options, CancellationToken cancellationToken) { var item = GetItem(index); if (item is null) { return(false); } var workspace = item.Workspace; var solution = workspace.CurrentSolution; var documentId = item.DocumentId; if (documentId is null) { if (item is { ProjectId : { } projectId } &&