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