5
5
6
6
namespace BlocklyNet . Scripting . Engine ;
7
7
8
- public partial class ScriptEngine
8
+ partial class ScriptEngine < TLogType >
9
9
{
10
10
/// <summary>
11
11
/// Helper class to manage nested script calls.
12
12
/// </summary>
13
- protected class ScriptSite : IScriptSite , IGroupManagerSite
13
+ protected class ScriptSite : IScriptSite < TLogType > , IGroupManagerSite
14
14
{
15
15
/// <summary>
16
16
///
@@ -19,7 +19,7 @@ protected class ScriptSite : IScriptSite, IGroupManagerSite
19
19
/// <param name="parent">Parent script.</param>
20
20
/// <param name="depth">Nestring depth of the script, at least 1.</param>
21
21
/// <param name="groupManager">Group management for this nested script only.</param>
22
- public ScriptSite ( ScriptEngine engine , IScript ? parent , int depth , ISiteGroupManager groupManager )
22
+ public ScriptSite ( ScriptEngine < TLogType > engine , IScript < TLogType > ? parent , int depth , ISiteGroupManager groupManager )
23
23
{
24
24
_depth = depth ;
25
25
_engine = engine ;
@@ -44,7 +44,7 @@ public ScriptSite(ScriptEngine engine, IScript? parent, int depth, ISiteGroupMan
44
44
/// <summary>
45
45
/// The script starting this script.
46
46
/// </summary>
47
- protected readonly IScript ? Parent ;
47
+ protected readonly IScript < TLogType > ? Parent ;
48
48
49
49
/// <summary>
50
50
/// Synchronize access to the result.
@@ -70,7 +70,7 @@ public ScriptSite(ScriptEngine engine, IScript? parent, int depth, ISiteGroupMan
70
70
/// <summary>
71
71
/// The main script engine.
72
72
/// </summary>
73
- private readonly ScriptEngine _engine ;
73
+ private readonly ScriptEngine < TLogType > _engine ;
74
74
75
75
/// <inheritdoc/>
76
76
public IServiceProvider ServiceProvider => _engine . ServiceProvider ;
@@ -85,10 +85,16 @@ public ScriptSite(ScriptEngine engine, IScript? parent, int depth, ISiteGroupMan
85
85
public bool MustPause => _engine . MustPause ;
86
86
87
87
/// <inheritdoc/>
88
- public IScript ? CurrentScript { get ; private set ; }
88
+ public IScript < TLogType > ? CurrentScript { get ; private set ; }
89
89
90
90
/// <inheritdoc/>
91
- public IScript ? MainScript => _engine . MainScript ;
91
+ public IScript < TLogType > ? MainScript => _engine . MainScript ;
92
+
93
+ /// <inheritdoc/>
94
+ IScript ? IScriptSite . CurrentScript => CurrentScript ;
95
+
96
+ /// <inheritdoc/>
97
+ IScript ? IScriptSite . MainScript => MainScript ;
92
98
93
99
/// <inheritdoc/>
94
100
public Task < object ? > EvaluateAsync ( string scriptAsXml , Dictionary < string , object ? > presets )
@@ -154,7 +160,7 @@ public void Start(StartScript request, StartScriptOptions? options = null)
154
160
try
155
161
{
156
162
/* Create the script instance from the configuration model. */
157
- if ( Activator . CreateInstance ( request . GetScriptType ( ) , request , this , options ) is not Script script )
163
+ if ( Activator . CreateInstance ( request . GetScriptType ( ) , request , this , options ) is not IScriptInstance < TLogType > script )
158
164
throw new ArgumentException ( "bad script for '{Name}' request." , request . Name ) ;
159
165
160
166
/* Start the background execution of the script. */
@@ -171,7 +177,7 @@ public void Start(StartScript request, StartScriptOptions? options = null)
171
177
/// <summary>
172
178
/// Process the script.
173
179
/// </summary>
174
- private async Task RunScriptAsync ( Script script )
180
+ private async Task RunScriptAsync ( IScriptInstance < TLogType > script )
175
181
{
176
182
try
177
183
{
@@ -218,6 +224,9 @@ private async Task RunScriptAsync(Script script)
218
224
219
225
/// <inheritdoc/>
220
226
public virtual Task DoneExecuteGroupAsync ( GroupStatus status ) => Task . CompletedTask ;
227
+
228
+ /// <inheritdoc/>
229
+ public Task UpdateLogAsync ( ) => CurrentScript == null ? Task . CompletedTask : _engine . UpdateResultLogEntryAsync ( CurrentScript , Parent , false ) ;
221
230
}
222
231
223
232
/// <summary>
@@ -227,7 +236,7 @@ private async Task RunScriptAsync(Script script)
227
236
/// <param name="depth">Nesting depth.</param>
228
237
/// <param name="groupManager">Execution group management helper.</param>
229
238
/// <returns>The new site.</returns>
230
- protected virtual ScriptSite CreateSite ( IScript ? parent , int depth , IGroupManager groupManager )
239
+ protected virtual ScriptSite CreateSite ( IScript < TLogType > ? parent , int depth , IGroupManager groupManager )
231
240
=> new ( this , parent , depth , groupManager ) ;
232
241
233
242
/// <summary>
@@ -240,7 +249,7 @@ protected virtual ScriptSite CreateSite(IScript? parent, int depth, IGroupManage
240
249
/// <param name="depth">Nestring depth of the child.</param>
241
250
/// <param name="groupManager">Parent group manager to allow for any-depth nesting.</param>
242
251
/// <returns>Task on the result.</returns>
243
- protected virtual async Task < TResult > StartChildAsync < TResult > ( StartScript request , IScript ? parent , StartScriptOptions ? options , int depth , ISiteGroupManager groupManager )
252
+ protected virtual async Task < TResult > StartChildAsync < TResult > ( StartScript request , IScript < TLogType > ? parent , StartScriptOptions ? options , int depth , ISiteGroupManager groupManager )
244
253
{
245
254
/* Create execution context. */
246
255
var site = CreateSite ( parent , depth + 1 , await groupManager . CreateNestedAsync ( ( request as IStartGenericScript ) ? . ScriptId ?? string . Empty , request . Name ) ) ;
0 commit comments