Skip to content

Commit

Permalink
b
Browse files Browse the repository at this point in the history
  • Loading branch information
polterguy committed Nov 12, 2023
1 parent 8a159db commit d7310f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
30 changes: 9 additions & 21 deletions backend/files/etc/snippets/system.compile.hl
Original file line number Diff line number Diff line change
@@ -1,35 +1,23 @@
/*
* Compiles a snippet of C# code down to a library,
* for then to dynamically load it as a plugin.
* Compiles a C# file and creates a library from the compiled result,
* for then to dynamically load it as a plugin and invoke a slot
* called [foo] expected to exist within the C# code.
*
* This particular code creates a slot, but you can create any
* code you wish, and it doesn't have to be Hyperlambda related.
* Notice, the code assumes there's a C# file called "slot.cs"
* in your '/etc/csharp/' folder. Create this file with Hyper IDE
* using the "slot" template to test the code.
*/
io.file.load:/etc/csharp/slot.cs
system.compile
references
.:netstandard
.:System.Runtime
.:System.ComponentModel
.:System.Private.CoreLib
.:magic.node
.:magic.node.extensions
.:magic.signals.contracts
code:@"

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

// Our slot class.
[Slot(Name = ""foo"")]
public class Foo : ISlot
{
public void Signal(ISignaler signaler, Node input)
{
input.Value = $""Hi {input.GetEx<string>()}, how may I assist you?"";
}
}"
code:x:@io.file.load
assembly-name:foo.dll

// Loading assembly now that we've created it and saved it.
Expand Down
3 changes: 2 additions & 1 deletion backend/files/misc/ide/templates/slot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;

using magic.node;
using magic.node.extensions;
using magic.signals.contracts;
using magic.node.contracts;

Expand All @@ -19,6 +20,6 @@ public Foo(IServiceProvider services)
public void Signal(ISignaler signaler, Node input)
{
var configuration = (IMagicConfiguration)_services.GetService(typeof(IMagicConfiguration));
input.Value = configuration["magic:smtp:host"];
input.Value = $"Hello {input.GetEx<string>()} your SMTP server is {configuration["magic:smtp:host"]}";
}
}

0 comments on commit d7310f6

Please sign in to comment.