System.IO.Packaging.PackUriHelper.GetPartUri C# (CSharp) Méthode

GetPartUri() public static méthode

public static GetPartUri ( Uri packUri ) : Uri
packUri Uri
Résultat Uri
        public static Uri GetPartUri(Uri packUri)
        {
            Check.PackUri(packUri);
            Check.PackUriIsValid(packUri);

            if (string.IsNullOrEmpty(packUri.AbsolutePath) || packUri.AbsolutePath == "/")
                return null;

            return new Uri(packUri.AbsolutePath, UriKind.Relative);
        }

Usage Example

        /// <summary>
        /// Resolves the target uri in the relationship against the source part or the
        /// package root. This resolved Uri is then used by the Add method to figure
        /// out if a relationship is being created to another relationship part.
        /// </summary>
        /// <param name="target">PackageRelationship target uri</param>
        /// <param name="targetMode"> Enum value specifying the interpretation of the base uri
        /// for the relationship target uri</param>
        /// <returns>Resolved Uri</returns>
        private Uri GetResolvedTargetUri(Uri target, TargetMode targetMode)
        {
            if (targetMode == TargetMode.Internal)
            {
                Debug.Assert(!target.IsAbsoluteUri, "Uri should be relative at this stage");

                if (_sourcePart == null) //indicates that the source is the package root
                {
                    return(PackUriHelper.ResolvePartUri(PackUriHelper.PackageRootUri, target));
                }
                else
                {
                    return(PackUriHelper.ResolvePartUri(_sourcePart.Uri, target));
                }
            }
            else
            {
                if (target.IsAbsoluteUri)
                {
                    if (String.CompareOrdinal(target.Scheme, PackUriHelper.UriSchemePack) == 0)
                    {
                        return(PackUriHelper.GetPartUri(target));
                    }
                }
                else
                {
                    Debug.Assert(false, "Uri should not be relative at this stage");
                }
            }
            // relative to the location of the package.
            return(target);
        }
All Usage Examples Of System.IO.Packaging.PackUriHelper::GetPartUri