예제 #1
0
 private bool Validate(out Exception error)
 {
     error = null;
     if (Epoch < 0)
     {
         error = new FormatException("Epoch must be 0 or greater");
         return(false);
     }
     if (Release != null && Release.Any(i => i < 0))
     {
         error = new FormatException("All components of Release must be 0 or greater");
         return(false);
     }
     if (PreReleaseName == PackageVersionPreReleaseName.None)
     {
         if (PreRelease != 0)
         {
             error = new FormatException("PreRelease must be 0 when PreReleaseName is None");
             return(false);
         }
     }
     else
     {
         if (PreRelease < 0)
         {
             error = new FormatException("PreRelease must be 0 or greater");
             return(false);
         }
     }
     if (PostRelease < 0)
     {
         error = new FormatException("PostRelease must be 0 or greater");
         return(false);
     }
     if (DevRelease < 0)
     {
         error = new FormatException("DevRelease must be 0 or greater");
         return(false);
     }
     if (!string.IsNullOrEmpty(LocalVersion) && !LocalVersionRegex.IsMatch(LocalVersion))
     {
         error = new FormatException("LocalVersion has invalid characters");
         return(false);
     }
     return(true);
 }