HarmonyCore
HarmonyCore copied to clipboard
Determine file specs at runtime
Occasionally a repository may not include a complete specification for the data file to be opened. In some cases only the file name is entered in the repository, the location of the file to be determined at run-time, and in other cases special code or tokens are used within the file spec, and are replaced at run-time. We need a way to allow developers to inject file names at run-time.
Aha! Link: https://synergex.aha.io/features/HC-84
The Entity Framework provider already has a mechanism to do this and we will provide a WiKi page that describes the process.
To do this one would write a class that inherits from Harmony.Core.FileIO.FileChannelManager, overrides the OpenChannel method, provides a custom value for fileName, then calls parent.OpenChannel. An example can be found in Harmony.Core.FileIO.HookableFileChannelManager. If you need custom file specs AND I/O hooks then inherit from Harmony.Core.FileIO.HookableFileChannelManager instead.
Having created the custom class you need to make it available through dependency injection by adding code in Startup.ConfigureServicesCustom()