public bool WithPage(Metadata metadata, int pageIndex, Action <string> action) { if (metadata == null || pageIndex < 0 || pageIndex > metadata.Images.Pages.Count - 1) { return(false); } string pageCachedFilePath; if (PathFormatter.IsEnabled) { pageCachedFilePath = PathFormatter.GetPage(metadata, pageIndex); } else { string paddedIndex = (pageIndex + 1).ToString(CultureInfo.InvariantCulture).PadLeft(GetBaseCount(metadata.Images.Pages.Count), '0'); pageCachedFilePath = string.Format(CultureInfo.InvariantCulture, "{0}{1}/{2}{3}", PathFormatter.GetCacheDirectory(), metadata.Id, paddedIndex, metadata.Images.Pages[pageIndex].GetFileExtension()); } if (!File.Exists(pageCachedFilePath)) { return(false); } if (action != null) { action.Invoke(pageCachedFilePath); } return(true); }