Utility package to programmatically create an instance of a software backend class from a C# software executable or DLL implementing a desired public class or interface.
$ dotnet add package LC.RuntimeLC.Runtime is a .NET Standard 2.0 (C#) utility to programmatically create an instance of a software backend class from a C# software executable or DLL implementing a desired public class or interface.
LC.Runtime superseeds parts of LabCognition.Interface. Interfaces and methods used in LabCognition.Interface have been revised, renamed and extracted into LC.Runtime.
Here is a matrix depicting the changes:
| LabCognition.Interface (1.2.0) | LC.Runtime (0.1.0) | Action |
|---|---|---|
| IPredictionEngineFactory | IPredictorFactory | interface renamed and enhanced |
| InstanceFactory class | InstanceFactory class | moved |
| MsiApi class | MsiApi class | moved |
| MsiConfig class | MsiConfig class | moved and enhanced to support external configuration file |
| Plugin class | Plugin class | moved |
| KnownMsi list | KnownMsi list | Change handling by reading list from json MsiConfig.config file |
Using the LabCognition software suite in 3rd party applications, you must create an instance of the software or one of its public classes to programatically access its features. The utility features provided herein allow to create such instance.
Available methods either work on a C# DLL or a C# application executable file implementing the desired public class or interface.
An instance of the class implementing the interface in the backend software is created and returned during runtime of a client software.
The instance of the class containing the desired interface is created using the Create method. Depending on the input string the instance is created using the options below in the given order. In case an option fails, the next in the list is applied.
Call the Create method with a fully qualified path to the predictor software executable file
Example:
ITargetInterface softwareInterface = Create(@"c:\Program Files (x86)\Software\MySoftware.exe");
TargetClass softwareClass = Create(@"c:\Program Files (x86)\Software\MySoftware.exe");
Product code and upgrade code are GUIDs typically used when installing software on a Windows computer. The upgrade code and the executable file name are used to lookup in the Windows registry for matching installed applications. Both can be handled by the Create method. The input string in this case consists of both in formation using the pipe ('|') symbol as separator.
Example: Using LabCognition's Panorama software
ITargetInterface softwareInterface = Create(@"{89774630-f0ed-4e55-a49c-0fc148754ac5}|Panorama.exe");
TargetClass softwareClass = Create(@"{89774630-f0ed-4e55-a49c-0fc148754ac5}|Panorama.exe");
Alternatively, pairs consisting of upgrade code and software executable name formatted as described above can be provided in a file named MsiConfig.config. Such file is assumed to be located in the calling software executable's folder by default.
Example: MsiConfig.config file
[
{ "ProductCode":"productCode A", "ExecutableFileName":"executable A"},
{ "ProductCode":"productCode B", "ExecutableFileName":"executable B"}
]
You may also define a custom location by changing the ConfigPath property. Use the Create method with empty string input to force this option to be used.