Class FileCompilerCache
- Namespace
- Ecng.Compilation
- Assembly
- Ecng.Compilation.dll
A file-based implementation of InMemoryCompilerCache that persists cached assemblies to disk.
public class FileCompilerCache : InMemoryCompilerCache, ICompilerCache
- Inheritance
-
FileCompilerCache
- Implements
- Inherited Members
- Extension Methods
Constructors
FileCompilerCache(string, TimeSpan)
A file-based implementation of InMemoryCompilerCache that persists cached assemblies to disk.
public FileCompilerCache(string path, TimeSpan timeout)
Parameters
Methods
Add(string, IEnumerable<string>, IEnumerable<string>, byte[])
Adds a compiled assembly to the file-based cache and persists it on disk.
public override void Add(string ext, IEnumerable<string> sources, IEnumerable<string> refs, byte[] assembly)
Parameters
ext
stringThe file extension used in key generation.
sources
IEnumerable<string>The source code files.
refs
IEnumerable<string>The referenced assemblies.
assembly
byte[]The compiled assembly bytes to cache.
Exceptions
- ArgumentNullException
Thrown when assembly is null.
Clear()
Clears the in-memory cache and deletes all cached files from disk.
public override void Clear()
Init()
Initializes the file-based cache by ensuring the directory exists and loading valid cached files.
public override void Init()
Remove(string, IEnumerable<string>, IEnumerable<string>)
Removes a cached assembly from both the file system and the in-memory cache.
public override bool Remove(string ext, IEnumerable<string> sources, IEnumerable<string> refs)
Parameters
ext
stringThe file extension used in key generation.
sources
IEnumerable<string>The source code files.
refs
IEnumerable<string>The referenced assemblies.
Returns
- bool
true if the assembly was removed; otherwise, false.
TryGet(string, IEnumerable<string>, IEnumerable<string>, out byte[])
Tries to retrieve a cached assembly from the in-memory cache or from disk if not present in memory.
public override bool TryGet(string ext, IEnumerable<string> sources, IEnumerable<string> refs, out byte[] assembly)
Parameters
ext
stringThe file extension used in key generation.
sources
IEnumerable<string>The source code files.
refs
IEnumerable<string>The referenced assemblies.
assembly
byte[]When this method returns, contains the cached assembly if found; otherwise, null.
Returns
- bool
true if the assembly was retrieved; otherwise, false.