HarmonyCore icon indicating copy to clipboard operation
HarmonyCore copied to clipboard

Determine file specs at runtime

Open SteveIves opened this issue 6 years ago • 2 comments

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

SteveIves avatar Oct 16 '18 06:10 SteveIves

The Entity Framework provider already has a mechanism to do this and we will provide a WiKi page that describes the process.

SteveIves avatar Oct 16 '18 16:10 SteveIves

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()

SteveIves avatar Oct 19 '18 22:10 SteveIves