forked from ZeraGmbH/Blockly.Net
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScriptCore.cs
More file actions
68 lines (54 loc) · 1.97 KB
/
ScriptCore.cs
File metadata and controls
68 lines (54 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using BlocklyNet.Scripting.Engine;
namespace BlocklyNet.Scripting;
/// <summary>
/// Describes an active script.
/// </summary>
public abstract class Script : IScriptInstance, IScript
{
/// <summary>
/// The unique identifier of the active script.
/// </summary>
public string JobId { get; private set; } = Guid.NewGuid().ToString().ToUpper();
/// <inheritdoc/>
public object? Result { get; protected set; }
/// <inheritdoc/>
public abstract Task ExecuteAsync();
/// <inheritdoc/>
public abstract StartScript GetRequest();
/// <inheritdoc/>
public abstract IScriptSite Engine { get; }
/// <summary>
/// Can be used to check for early termination.
/// </summary>
public abstract StartScriptOptions? Options { get; }
/// <summary>
/// Call to do some internal reset of the script.
/// </summary>
public async Task ResetAsync()
{
// Self.
JobId = Guid.NewGuid().ToString().ToUpper();
Result = null;
// Derived class.
await OnResetAsync();
}
/// <summary>
/// Call to do some internal reset of the script.
/// </summary>
protected virtual Task OnResetAsync() => throw new NotSupportedException($"can not restart {GetType().FullName}");
/// <summary>
/// Report the start of a group execution.
/// </summary>
/// <param name="status">Status pf the group.</param>
/// <param name="repeat">Set if this is a repeat operation and results should be recovered.</param>
public abstract Task BeginGroupExecutionAsync(GroupStatus status, bool repeat);
/// <summary>
/// A group has finished execution - not called for repeat.
/// </summary>
/// <param name="status">Status of the completed group.</param>
public abstract Task EndGroupExecutionAsync(GroupStatus status);
/// <inheritdoc/>
public abstract void SetGroups(ScriptGroupStatus? status);
/// <inheritdoc/>
StartScript IScript.Request => GetRequest();
}