Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NavigationContext"/> class for a region name and a
        /// <see cref="Uri"/>.
        /// </summary>
        /// <param name="navigationService">The navigation service.</param>
        /// <param name="navigationParameters">The navigation parameters.</param>
        /// <param name="uri">The Uri.</param>
        public NavigationContext(IRegionNavigationService navigationService, Uri uri, NavigationParameters navigationParameters)
        {
            NavigationService = navigationService;
            Uri        = uri;
            Parameters = uri != null?UriParsingHelper.ParseQuery(uri) : null;

            GetNavigationParameters(navigationParameters);
        }
        /// <summary>
        /// Returns the candidate TargetContract based on the <see cref="NavigationContext"/>.
        /// </summary>
        /// <param name="navigationContext">The navigation contract.</param>
        /// <returns>The candidate contract to seek within the <see cref="IRegion"/> and to use, if not found, when resolving from the container.</returns>
        protected virtual string GetContractFromNavigationContext(NavigationContext navigationContext)
        {
            if (navigationContext == null)
            {
                throw new ArgumentNullException(nameof(navigationContext));
            }
            var candidateTargetContract = UriParsingHelper.GetAbsolutePath(navigationContext.Uri);

            candidateTargetContract = candidateTargetContract.TrimStart('/');
            return(candidateTargetContract);
        }