| | 1 | |
|
| | 2 | |
|
| | 3 | | using Kestrun.Hosting; |
| | 4 | |
|
| | 5 | | namespace Kestrun.Languages; |
| | 6 | | // --------------------------------------------------------------------------- |
| | 7 | | // C# delegate builder – now takes optional imports / references |
| | 8 | | // --------------------------------------------------------------------------- |
| | 9 | | /// <summary> |
| | 10 | | /// Provides global and local variable dictionaries and context for C# delegate execution. |
| | 11 | | /// </summary> |
| | 12 | | public record CsGlobals |
| | 13 | | { |
| | 14 | | /// <summary> |
| | 15 | | /// Initializes a new instance of the <see cref="CsGlobals"/> class with the specified global variables. |
| | 16 | | /// </summary> |
| | 17 | | /// <param name="globals">A dictionary containing global variables.</param> |
| 6 | 18 | | public CsGlobals(IReadOnlyDictionary<string, object?> globals) |
| | 19 | | { |
| 6 | 20 | | Globals = globals; |
| 6 | 21 | | Locals = new Dictionary<string, object?>(); |
| 6 | 22 | | Context = null; |
| 6 | 23 | | } |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// Initializes a new instance of the <see cref="CsGlobals"/> class with the specified global variables and context. |
| | 27 | | /// </summary> |
| | 28 | | /// <param name="globals">A dictionary containing global variables.</param> |
| | 29 | | /// <param name="krcontext">The Kestrun execution context.</param> |
| 6 | 30 | | public CsGlobals(IReadOnlyDictionary<string, object?> globals, KestrunContext krcontext) |
| | 31 | | { |
| 6 | 32 | | Globals = globals; |
| 6 | 33 | | Context = krcontext; |
| 6 | 34 | | Locals = new Dictionary<string, object?>(); |
| 6 | 35 | | } |
| | 36 | |
|
| | 37 | | /// <summary> |
| | 38 | | /// Initializes a new instance with the specified global and local variables (no execution context). |
| | 39 | | /// </summary> |
| | 40 | | /// <param name="globals">Global variables.</param> |
| | 41 | | /// <param name="locals">Local variables.</param> |
| 1 | 42 | | public CsGlobals(IReadOnlyDictionary<string, object?> globals, IReadOnlyDictionary<string, object?> locals) |
| | 43 | | { |
| 1 | 44 | | Globals = globals; |
| 1 | 45 | | Locals = locals; |
| 1 | 46 | | Context = null; |
| 1 | 47 | | } |
| | 48 | |
|
| | 49 | | /// <summary> |
| | 50 | | /// Initializes a new instance of the <see cref="CsGlobals"/> class with the specified global variables, context, an |
| | 51 | | /// </summary> |
| | 52 | | /// <param name="globals">A dictionary containing global variables.</param> |
| | 53 | | /// <param name="krcontext">The Kestrun execution context.</param> |
| | 54 | | /// <param name="locals">A dictionary containing local variables.</param> |
| 13 | 55 | | public CsGlobals(IReadOnlyDictionary<string, object?> globals, KestrunContext krcontext, IReadOnlyDictionary<string, |
| | 56 | | { |
| 13 | 57 | | Globals = globals; |
| 13 | 58 | | Context = krcontext; |
| 13 | 59 | | Locals = locals; |
| 13 | 60 | | } |
| | 61 | |
|
| | 62 | | /// <summary> |
| | 63 | | /// Gets the dictionary containing global variables for delegate execution. |
| | 64 | | /// </summary> |
| 48 | 65 | | public IReadOnlyDictionary<string, object?> Globals { get; } |
| | 66 | |
|
| | 67 | | /// <summary> |
| | 68 | | /// Gets the dictionary containing local variables for delegate execution. |
| | 69 | | /// </summary> |
| 23 | 70 | | public IReadOnlyDictionary<string, object?> Locals { get; } |
| | 71 | |
|
| | 72 | | /// <summary> |
| | 73 | | /// Gets the Kestrun execution context for delegate execution. |
| | 74 | | /// </summary> |
| 32 | 75 | | public KestrunContext? Context { get; } |
| | 76 | | } |