Exemplo n.º 1
0
 protected static void FileExists(string filePath, ValidationFailedHandler validationFailed)
 {
     if (!File.Exists(filePath))
     {
         validationFailed("File doesn't exists - " + filePath);
     }
 }
Exemplo n.º 2
0
 protected static void NotNullOrEmpty(string value, ValidationFailedHandler validationFailed)
 {
     if (string.IsNullOrEmpty(value))
     {
         validationFailed("Value is null or empty.");
     }
 }
Exemplo n.º 3
0
 protected static void NotNull(object value, ValidationFailedHandler validationFailed)
 {
     if (value == null)
     {
         validationFailed("Value is null.");
     }
 }
Exemplo n.º 4
0
 protected static void MoreThanZero <T>(T value, ValidationFailedHandler validationFailed) where T : IComparable
 {
     if (value.CompareTo(Convert.ChangeType(0, typeof(T))) <= 0)
     {
         validationFailed("Value is not more than zero.");
     }
 }
Exemplo n.º 5
0
 protected static void ValidVersionId(int versionId, ValidationFailedHandler validationFailed)
 {
     if (versionId < 0)
     {
         validationFailed("Invalid verison id - " + versionId);
     }
 }
Exemplo n.º 6
0
 protected static void DirectoryExists(string dirPath, ValidationFailedHandler validationFailed)
 {
     if (dirPath == null)
     {
         validationFailed("Directory doesn't exists - null");
     }
     else if (!Directory.Exists(dirPath))
     {
         validationFailed("Directory doesn't exists - " + dirPath);
     }
 }
Exemplo n.º 7
0
        protected static void ValidRemoteResource(RemoteResource resource, ValidationFailedHandler validationFailed)
        {
            if (resource.Size <= 0)
            {
                validationFailed("Resource size is not more than zero - " + resource.Size);
            }
            // TODO: Sometimes it is...

            /*else if (string.IsNullOrEmpty(resource.HashCode))
             * {
             *  validationFailed("Resource hash code is null or empty.");
             * }*/
            else if (resource.GetUrls().Length == 0)
            {
                validationFailed("Resource urls are null or empty.");
            }
        }
Exemplo n.º 8
0
        protected static void ParentDirectoryExists(string path, ValidationFailedHandler validationFailed)
        {
            if (path == null)
            {
                validationFailed("Cannot find parent directory of null path.");
            }

            string dirPath = Path.GetDirectoryName(path);

            if (dirPath == null)
            {
                validationFailed("Cannot find parent directory of root path.");
            }
            else if (!Directory.Exists(dirPath))
            {
                validationFailed("Parent directory doesn't exist - " + path);
            }
        }