Skip to content

Commit

Permalink
Create system.plugin.execute.hl
Browse files Browse the repository at this point in the history
  • Loading branch information
polterguy committed Nov 11, 2023
1 parent b0d27ed commit 6db7d15
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions backend/files/etc/snippets/system.plugin.execute.hl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Compiles a snippet of C# code down to a library,
* for then to dynamically load it as a plugin.
*
* This particular code creates a slot, but you can create any
* code you wish, and it doesn't have to be Hyperlambda related.
*/
system.compile
references
.:netstandard
.:System.Runtime
.:System.Private.CoreLib
.:magic.node
.:magic.signals.contracts
code:@"

// Example C# code creating a Hyperlambda slot.
using System;
using magic.node;
using magic.signals.contracts;

// Our slot class.
[Slot(Name = ""bar"")]
public class Bar : ISlot
{
public void Signal(ISignaler signaler, Node input)
{
input.Value = ""Hello from C#"";
}
}"
assembly-name:bar.dll

// Loading assembly now that we've created it.
system.plugin.execute:x:@system.compile

// Invoking dynamically created C# slot.
bar

0 comments on commit 6db7d15

Please sign in to comment.