public PatchingTemplate GetTemplate(ITransformationContext transformationContext, string templateName)
        {
            string templatePath = Path.Combine(_templateFolder, templateName + _templateExtension);

            if (!File.Exists(templatePath))
            {
                throw new FileNotFoundException(templatePath);
            }

            return(transformationContext.GetOrAddCacheEntry(templatePath, () => new PatchingTemplate
            {
                Name = templateName,
                Path = templatePath,
                String = File.ReadAllText(templatePath)
            }));
        }
 private ImmutableSortedDictionary <string, string> GetPatchCache(
     ITransformationContext transformationContext,
     IIncludeContext includeContext,
     string patchToken)
 {
     return(transformationContext
            .GetOrAddCacheEntry(
                includeContext.IncludeRoot + "|" + patchToken,
                () => includeContext
                .ResolvedIncludeRoots
                .SelectMany(r => Directory.GetFiles(r, $"*{patchToken}", SearchOption.AllDirectories))
                .Distinct()
                .Select(path => (path, File.ReadAllText(path)))
                .OrderBy(p => Path.GetRelativePath(includeContext.IncludeRoot, p.Item1))
                .ToImmutableSortedDictionary(k => k.Item1, v => v.Item2)));
 }