示例#1
0
        // Token: 0x06007D2D RID: 32045 RVA: 0x00232EA8 File Offset: 0x002310A8
        internal static Uri GetUriToNavigate(DependencyObject element, Uri baseUri, Uri inputUri)
        {
            if (inputUri == null || inputUri.IsAbsoluteUri)
            {
                return(inputUri);
            }
            if (BindUriHelper.StartWithFragment(inputUri))
            {
                baseUri = null;
            }
            Uri resolvedUri;

            if (baseUri != null)
            {
                if (!baseUri.IsAbsoluteUri)
                {
                    resolvedUri = BindUriHelper.GetResolvedUri(BindUriHelper.GetResolvedUri(null, baseUri), inputUri);
                }
                else
                {
                    resolvedUri = BindUriHelper.GetResolvedUri(baseUri, inputUri);
                }
            }
            else
            {
                Uri uri = null;
                if (element != null)
                {
                    INavigator navigator = element as INavigator;
                    if (navigator != null)
                    {
                        uri = navigator.CurrentSource;
                    }
                    else
                    {
                        NavigationService navigationService = element.GetValue(NavigationService.NavigationServiceProperty) as NavigationService;
                        uri = ((navigationService == null) ? null : navigationService.CurrentSource);
                    }
                }
                if (uri != null)
                {
                    if (uri.IsAbsoluteUri)
                    {
                        resolvedUri = BindUriHelper.GetResolvedUri(uri, inputUri);
                    }
                    else
                    {
                        resolvedUri = BindUriHelper.GetResolvedUri(BindUriHelper.GetResolvedUri(null, uri), inputUri);
                    }
                }
                else
                {
                    resolvedUri = BindUriHelper.GetResolvedUri(null, inputUri);
                }
            }
            return(resolvedUri);
        }
示例#2
0
        // Token: 0x06007D30 RID: 32048 RVA: 0x00232FC8 File Offset: 0x002311C8
        internal static Uri GetUriRelativeToPackAppBase(Uri original)
        {
            if (original == null)
            {
                return(null);
            }
            Uri resolvedUri    = BindUriHelper.GetResolvedUri(original);
            Uri packAppBaseUri = BaseUriHelper.PackAppBaseUri;

            return(packAppBaseUri.MakeRelativeUri(resolvedUri));
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <remarks>
        ///     Relative Uri resolution logic
        ///
        ///     if baseUriString != ""
        ///     {
        ///         if (baseUriString is absolute uri)
        ///         {
        ///             determine uriToNavigate as baseUriString + inputUri
        ///         }
        ///         else
        ///         {
        ///             determine uri to navigate wrt application's base uri + baseUriString + inputUri
        ///         }
        ///     }
        ///     else
        ///     {
        ///         Get the element's NavigationService
        ///         if(NavigationService.CurrentSource is absolute uri)
        ///         {
        ///             determine uriToNavigate as NavigationService.CurrentSource + inputUri
        ///         }
        ///         else // this will be more common
        ///         {
        ///             determine uriToNavigate wrt application's base uri (pack://application,,,/) + NavigationService.CurrentSource + inputUri
        ///         }
        ///
        ///
        ///         If no ns in tree, resolve against the application's base
        ///     }
        /// </remarks>
        /// <param name="element"></param>
        /// <param name="baseUri"></param>
        /// <param name="inputUri"></param>
        /// <returns></returns>
        static internal Uri GetUriToNavigate(DependencyObject element, Uri baseUri, Uri inputUri)
        {
            Uri uriToNavigate = inputUri;

            if ((inputUri == null) || (inputUri.IsAbsoluteUri == true))
            {
                return(uriToNavigate);
            }

            // BaseUri doesn't contain the last part of the path: filename,
            // so when the inputUri is fragment we cannot resolve with BaseUri, instead
            // we should resolve with the element's NavigationService's CurrentSource.
            if (StartWithFragment(inputUri))
            {
                baseUri = null;
            }

            if (baseUri != null)
            {
                if (baseUri.IsAbsoluteUri == false)
                {
                    uriToNavigate = GetResolvedUri(BindUriHelper.GetResolvedUri(null, baseUri), inputUri);
                }
                else
                {
                    uriToNavigate = GetResolvedUri(baseUri, inputUri);
                }
            }
            else // we're in here when baseUri is not set i.e. it's null
            {
                Uri currentSource = null;

                // if the it is an INavigator (Frame, NavWin), we should use its CurrentSource property.
                // Otherwise we need to get NavigationService of the container that this element is hosted in,
                // and use its CurrentSource.
                if (element != null)
                {
                    INavigator navigator = element as INavigator;
                    if (navigator != null)
                    {
                        currentSource = navigator.CurrentSource;
                    }
                    else
                    {
                        NavigationService ns = null;
                        ns            = element.GetValue(NavigationService.NavigationServiceProperty) as NavigationService;
                        currentSource = (ns == null) ? null : ns.CurrentSource;
                    }
                }

                if (currentSource != null)
                {
                    if (currentSource.IsAbsoluteUri)
                    {
                        uriToNavigate = GetResolvedUri(currentSource, inputUri);
                    }
                    else
                    {
                        uriToNavigate = GetResolvedUri(GetResolvedUri(null, currentSource), inputUri);
                    }
                }
                else
                {
                    //



                    // For now we resolve to Application's base
                    uriToNavigate = BindUriHelper.GetResolvedUri(null, inputUri);
                }
            }
            return(uriToNavigate);
        }
示例#4
0
 // Token: 0x06007D2C RID: 32044 RVA: 0x00232E9E File Offset: 0x0023109E
 internal static Uri GetResolvedUri(Uri originalUri)
 {
     return(BindUriHelper.GetResolvedUri(null, originalUri));
 }