From d7310f6ae5c7b6398686c1eb2aedc7542af02405 Mon Sep 17 00:00:00 2001
From: Thomas Hansen
Date: Sun, 12 Nov 2023 08:16:03 +0200
Subject: [PATCH] b
---
backend/files/etc/snippets/system.compile.hl | 30 ++++++--------------
backend/files/misc/ide/templates/slot.cs | 3 +-
2 files changed, 11 insertions(+), 22 deletions(-)
diff --git a/backend/files/etc/snippets/system.compile.hl b/backend/files/etc/snippets/system.compile.hl
index 82d4a6228f..37d506abd9 100644
--- a/backend/files/etc/snippets/system.compile.hl
+++ b/backend/files/etc/snippets/system.compile.hl
@@ -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()}, 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.
diff --git a/backend/files/misc/ide/templates/slot.cs b/backend/files/misc/ide/templates/slot.cs
index 29c5133f09..a6aeed1b5e 100644
--- a/backend/files/misc/ide/templates/slot.cs
+++ b/backend/files/misc/ide/templates/slot.cs
@@ -2,6 +2,7 @@
using System;
using magic.node;
+using magic.node.extensions;
using magic.signals.contracts;
using magic.node.contracts;
@@ -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()} your SMTP server is {configuration["magic:smtp:host"]}";
}
}
|