internal Uri BuildStream(string contentIdentifier, string relativePath)
        {
            if (string.IsNullOrWhiteSpace(contentIdentifier))
            {
                throw new ArgumentNullException(nameof(contentIdentifier));
            }

            if (string.IsNullOrWhiteSpace(relativePath))
            {
                throw new ArgumentNullException(nameof(relativePath));
            }

            // If not passing a relative path, the method faults. No exception is thrown, the application just fails fast
            // Until that issue resolved, add our own error checking
            if (PathUtilities.IsAbsolute(relativePath))
            {
                throw new ArgumentOutOfRangeException(nameof(relativePath), DesignerUI.E_WEBVIEW_INVALID_URI);
            }

            // The content identifier is used in conjunction with the application identity to create a guid. The
            // guid is appended to the win32webviewhost identity and a ms-local-stream URI is created.
            // Given a relative path of "/content.htm" the following is generated:
            // ms-local-stream://microsoft.win32webviewhost_xxxxxxxxxxxxx_yyyyyyyyyyyyyyyyyyyyyyyy//content.htm
            // If there is relative navigation items (e.g. "..\") they are resolved. URI will ALWAYS be relative to
            // the application container, e.g. "..\..\..\..\..\..\file" will resolve to "/file"
            return(_webViewControl?.BuildLocalStreamUri(contentIdentifier, relativePath));
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // The 'Host' part of the URI for the ms-local-stream protocol is a combination of the package name
            // and an application-defined key, which identifies the specfic resolver.
            // Here, we use 'MyTag'.

            Uri url = WebViewControl.BuildLocalStreamUri("MyTag", "/default.html");

            // The resolver object needs to be passed in to the navigate call.
            WebViewControl.NavigateToLocalStreamUri(url, myResolver);
        }
Example #3
0
 public void NavigateToFile(string url)
 {
     if (string.IsNullOrWhiteSpace(config.ExternalHost))
     {
         var uri = webview.BuildLocalStreamUri("spidereye", url);
         webview.NavigateToLocalStreamUri(uri, streamResolver);
     }
     else
     {
         var uri = UriTools.Combine(config.ExternalHost, url);
         webview.Navigate(uri);
     }
 }
        public void LoadUri(Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException(nameof(uri));
            }

            if (uri.IsAbsoluteUri)
            {
                webview.Navigate(uri);
            }
            else
            {
                var localUri = webview.BuildLocalStreamUri("spidereye", uri.ToString());
                webview.NavigateToLocalStreamUri(localUri, EdgeUriToStreamResolver.Instance);
            }
        }
Example #5
0
 internal Uri BuildStream(string contentIdentifier, string relativePath)
 {
     return(_webViewControl?.BuildLocalStreamUri(contentIdentifier, relativePath));
 }