Bloom.Book.BookStorage.CheckBook C# (CSharp) Метод

CheckBook() публичный Метод

The image-replacement feature is perhaps a one-off for a project where an advisor replaced the folders with a version that lacked most of the images (perhaps because dropbox copies small files first and didn't complete the sync)
public CheckBook ( IProgress progress, string pathToFolderOfReplacementImages = null ) : void
progress IProgress
pathToFolderOfReplacementImages string We'll find any matches in the entire folder, regardless of sub-folder name
Результат void
        public void CheckBook(IProgress progress, string pathToFolderOfReplacementImages = null)
        {
            var error = GetValidateErrors();
            if(!string.IsNullOrEmpty(error))
                progress.WriteError(error);

            //check for missing images

            foreach (XmlElement imgNode in HtmlDom.SelectChildImgAndBackgroundImageElements(Dom.Body))
            {
                var imageFileName = HtmlDom.GetImageElementUrl(imgNode).PathOnly.NotEncoded;
                if (string.IsNullOrEmpty(imageFileName))
                {
                    var classNames=imgNode.GetAttribute("class");
                    if (classNames == null || !classNames.Contains("licenseImage"))//bit of hack... it's ok for licenseImages to be blank
                    {
                        progress.WriteWarning("image src is missing");
                        //review: this, we could fix with a new placeholder... maybe in the javascript edit stuff?
                    }
                    continue;
                }
                // Certain .svg files (cogGrey.svg, FontSizeLetter.svg) aren't really part of the book and are stored elsewhere.
                // Also, at present the user can't insert them into a book. Don't report them.
                // TODO: if we ever allow the user to add .svg files, we'll need to change this
                if (Path.HasExtension(imageFileName) && Path.GetExtension(imageFileName).ToLowerInvariant() == ".svg")
                    continue;

                // Branding images are handled in a special way in BrandingApi.cs.
                // Without this, we get "Warning: Image /bloom/api/branding/image is missing from the folder xxx" (see BL-3975)
                if (imageFileName.EndsWith(BrandingApi.kBrandingImageUrlPart))
                    continue;

                //trim off the end of "license.png?123243"
                var startOfDontCacheHack = imageFileName.IndexOf('?');
                if (startOfDontCacheHack > -1)
                    imageFileName = imageFileName.Substring(0, startOfDontCacheHack);

                while (Uri.UnescapeDataString(imageFileName) != imageFileName)
                    imageFileName = Uri.UnescapeDataString(imageFileName);

                if (!RobustFile.Exists(Path.Combine(_folderPath, imageFileName)))
                {
                    if (!string.IsNullOrEmpty(pathToFolderOfReplacementImages))
                    {
                        if (!AttemptToReplaceMissingImage(imageFileName, pathToFolderOfReplacementImages, progress))
                        {
                            progress.WriteWarning(string.Format("Could not find replacement for image {0} in {1}", imageFileName, _folderPath));
                        }
                    }
                    else
                    {
                        progress.WriteWarning(string.Format("Image {0} is missing from the folder {1}", imageFileName, _folderPath));
                    }
                }
            }
        }