Skip to main content

Using external assemblies

When to use

While the JetVeo platform allows for complex logic, using an External Assembly Resource can often be benefitial.

Some of the main use cases include:

  • Code reused across many applications.
  • Already existing libraries.
  • Need for easily debugging the code.
  • Code that exceeds a certain threshold of complexity.
  • Custom compile flags.

Main drawbacks

  • External assembly code does not recognize other code on the platform. (This includes entities, interfaces, database...)
  • Difficult version control. (In the current state)

Add assemblies to the app

NuGet packages

One type of external assembly you might want to use is a NuGet package. In this case, navigate to Config > Rerources > Add resource > Add NuGet package assembly resource. You can then search for the desired NuGet package, specify the version, and click (+) Add package.

Your own binaries

If you want the app to use code from your own library, navigate to Config > Resources > Add resource > Add External assembly resource. Then upload your .dll and .pdb files.

ADD_RES

Usage

External assemblies are dynamic libraries that do not recognize the entities and interfaces defined in the data section, nor do they recognize other platform code.

Platform code scopes

If you still want the library code to use the platform code, you can pass in lambda functions from the platform code, that capture objects as references from the scope they are declared in.

Here is a simple example:

External code

public delegate bool EventHandler(XDevice device, long Id); 

public class XDevice
{
private readonly string host;
private readonly int port;

public EventHandler OnEvent { get; init; } = (_, _) => false;
...

Platform code

...
var device = new Xdevice(...) {
OnEvent = (_, id)=>
{
App.Commands.ExampleCommand.InvokeAsync(...);
return db.ExampleEntitySet.Any(y => y.Id == id);
};
}
...