System.IO.Packaging.Check.PartUriIsValid C# (CSharp) Méthode

PartUriIsValid() public static méthode

public static PartUriIsValid ( Uri partUri ) : void
partUri System.Uri
Résultat void
        public static void PartUriIsValid(Uri partUri)
        {
            if (!partUri.OriginalString.StartsWith("/"))
                throw new ArgumentException("PartUris must start with '/'");

            if (partUri.IsAbsoluteUri)
                throw new ArgumentException("PartUris cannot be absolute");
        }

Usage Example

Exemple #1
0
        public static Uri Create(Uri packageUri, Uri partUri, string fragment)
        {
            Check.PackageUri(packageUri);
            Check.PackageUriIsValid(packageUri);

            if (partUri != null)
            {
                Check.PartUriIsValid(partUri);
            }

            if (fragment != null && (fragment.Length == 0 || fragment[0] != '#'))
            {
                throw new ArgumentException("Fragment", "Fragment must not be empty and must start with '#'");
            }

            // FIXME: Validate that partUri is a valid one? Must be relative, must start with '/'

            // First replace the slashes, then escape the special characters
            string orig = packageUri.OriginalString.Replace('/', ',');

            if (partUri != null)
            {
                orig += partUri.OriginalString;
            }

//			if (sb[sb.Length - 1] != '/')
//				sb.Append ('/');

            if (fragment != null)
            {
                orig += fragment;
            }

            return(new Uri("pack://" + orig));
        }
All Usage Examples Of System.IO.Packaging.Check::PartUriIsValid