/// <summary> /// Processes {{photo guid;human_identifier}} with a specified function - best use may be for easily building /// library code. /// </summary> /// <param name="toProcess"></param> /// <param name="pageConversion"></param> /// <param name="progress"></param> /// <returns></returns> private static string PhotoCodeProcess(string toProcess, Func <SinglePhotoPage, string> pageConversion, IProgress <string> progress) { if (string.IsNullOrWhiteSpace(toProcess)) { return(string.Empty); } progress?.Report("Searching for Photo Codes"); var resultList = BracketCodeCommon.ContentBracketCodeMatches(toProcess, BracketCodeToken); if (!resultList.Any()) { return(toProcess); } var context = Db.Context().Result; foreach (var loopMatch in resultList) { var dbPhoto = context.PhotoContents.FirstOrDefault(x => x.ContentId == loopMatch.contentGuid); if (dbPhoto == null) { continue; } progress?.Report($"Photo Code for {dbPhoto.Title} processed"); var singlePhotoInfo = new SinglePhotoPage(dbPhoto); toProcess = toProcess.Replace(loopMatch.bracketCodeText, pageConversion(singlePhotoInfo)); } return(toProcess); }
public static void GenerateHtml(PhotoContent toGenerate, DateTime?generationVersion, IProgress <string> progress) { progress?.Report($"Photo Content - Generate HTML for {toGenerate.Title}"); var htmlContext = new SinglePhotoPage(toGenerate) { GenerationVersion = generationVersion }; htmlContext.WriteLocalHtml(); }