Ejemplo n.º 1
0
 public static void ValidateSource(string source)
 {
     if (!PathValidator.IsValidUrl(source))
     {
         throw new CommandLineException(NuGetResources.InvalidSource, source);
     }
 }
Ejemplo n.º 2
0
 public static string GetCanonicalPath(string path)
 {
     if (PathValidator.IsValidLocalPath(path) || (PathValidator.IsValidUncPath(path)))
     {
         return(Path.GetFullPath(EnsureTrailingSlash(path)));
     }
     if (PathValidator.IsValidUrl(path))
     {
         var url = new Uri(path);
         // return canonical representation of Uri
         return(url.AbsoluteUri);
     }
     return(path);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Validates that a source is a valid path or url.
 /// </summary>
 /// <param name="source">The path to validate.</param>
 /// <returns>True if valid, False if invalid.</returns>
 public static bool IsValidSource(string source)
 {
     return(PathValidator.IsValidLocalPath(source) || PathValidator.IsValidUncPath(source) || PathValidator.IsValidUrl(source));
 }
Ejemplo n.º 4
0
 public static string GetCanonicalPath(string path) =>
 ((PathValidator.IsValidLocalPath(path) || PathValidator.IsValidUncPath(path)) ? Path.GetFullPath(EnsureTrailingSlash(path)) : (!PathValidator.IsValidUrl(path) ? path : new Uri(path).AbsoluteUri));