Esempio n. 1
0
        private void performValidation()
        {
            //NB to maintainers: remember to call the base implementation as any calls to the current class will obviously infinitely recurse.
            string fileToFind = FTPSiteIndicator.FileName;
            bool   found      = false;

            //Firstly, determine if the current directory exists, if this is not the case, then throw an error.
            //Using the current library, the easiest way to do this is to perform a "List" and see if
            var allFiles = decorated.ListDirectory();

            if (!allFiles.Any() || (!hasMoreThanOne(allFiles) && String.IsNullOrWhiteSpace(allFiles.First())))
            {
                throw new InvalidFTPSiteException($"The supplied directory: {CurrentDirectory} on {Hostname} is not a folder.");
            }


            foreach (var f in allFiles)
            {
                if (f == fileToFind)
                {
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                throw InvalidFTPSiteException.FileNotFound(FTPSiteIndicator.FileName, CurrentDirectory, Hostname);
            }


            string           toConvert = decorated.DownloadFile(CurrentDirectory + fileToFind).ConvertToString(resetBeforeWriting: true);
            FTPSiteIndicator file      = FTPSiteIndicator.FromString(toConvert);

            if (file == null)
            {
                throw new InvalidFTPSiteException($"File: {fileToFind} found, but no content was detected.");
            }

            var validation = file.Validate();

            if (!validation.isValid)
            {
                throw new InvalidFTPSiteException(validation.ToString());
            }
        }
Esempio n. 2
0
 public static string ToJSONString(FTPSiteIndicator siteData) => siteData?.ToJSONString();