forked from ZeraGmbH/Blockly.Net
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGroupStatus.cs
More file actions
74 lines (63 loc) · 2.07 KB
/
Copy pathGroupStatus.cs
File metadata and controls
74 lines (63 loc) · 2.07 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
69
70
71
72
73
74
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
namespace BlocklyNet.Scripting.Engine;
/// <summary>
/// Result of a finished execution group.
/// </summary>
public class GroupStatusCommon
{
/// <summary>
/// Set to indicate that this is no a real group but a separate script.
/// </summary>
[NotNull, Required]
public bool IsScript { get; set; }
/// <summary>
/// Unique identifier of the group.
/// </summary>
[NotNull, Required]
public string Key { get; set; } = null!;
/// <summary>
/// Optional name of the group.
/// </summary>
public string? Name { get; set; }
/// <summary>
/// Optional details of the execution.
/// </summary>
public string? Details { get; set; }
/// <summary>
/// Result of the execution.
/// </summary>
public string? Result { get; set; }
/// <summary>
/// Save result of a group in a serialized form.
/// </summary>
/// <param name="result">Result to remember.</param>
/// <remarks>Without any external manipulation of JsonUtils.JsonSettings all
/// type informations will be lost.</remarks>
public void SetResult(GroupResult result) => Result = BlockyUtils.Compress(result);
/// <summary>
/// Reconstruct the result from the JSON string.
/// </summary>
/// <returns>Recostructed result.</returns>
public GroupResult? GetResult() => BlockyUtils.Decompress<GroupResult>(Result);
}
/// <summary>
/// Result of a finished execution group.
/// </summary>
public class GroupStatus<TChild> : GroupStatusCommon where TChild : GroupStatus<TChild>
{
/// <summary>
/// All executions started before this group has been finished.
/// </summary>
[NotNull, Required]
public List<TChild> Children { get; set; } = [];
/// <summary>
/// Some additional data to allow customization. Serialized to
/// a string.
/// </summary>
public string? CustomizerBlob { get; set; }
}
/// <summary>
/// Status information.
/// </summary>
public class GroupStatus : GroupStatus<GroupStatus> { }