using System.Reflection;
namespace Umbraco.Cms.Core.Composing;
///
/// Paths used to determine the
///
public sealed class RuntimeHashPaths
{
private readonly Dictionary _files = new();
private readonly List _paths = new();
public RuntimeHashPaths AddFolder(DirectoryInfo pathInfo)
{
_paths.Add(pathInfo);
return this;
}
///
/// Creates a runtime hash based on the assembly provider
///
///
///
public RuntimeHashPaths AddAssemblies(IAssemblyProvider assemblyProvider)
{
foreach (Assembly assembly in assemblyProvider.Assemblies)
{
// TODO: We need to test this on a published website
if (!assembly.IsDynamic && assembly.Location != null)
{
AddFile(new FileInfo(assembly.Location));
}
}
return this;
}
public void AddFile(FileInfo fileInfo, bool scanFileContent = false) => _files.Add(fileInfo, scanFileContent);
public IEnumerable GetFolders() => _paths;
public IReadOnlyDictionary GetFiles() => _files;
}