Skip to content

Commit 646010f

Browse files
committed
added runtime blocks
1 parent 4fbd06d commit 646010f

4 files changed

Lines changed: 20 additions & 3 deletions

File tree

src/NetCore2Blockly/NetCore2Blockly/BlocklyUIOptions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,13 @@ public BlocklyUIOptions()
3939
/// The custom blocks.
4040
/// </value>
4141
public string CustomBlocks { get; set; }
42+
43+
/// <summary>
44+
/// Gets or sets the run time blocks.
45+
/// </summary>
46+
/// <value>
47+
/// The run time blocks.
48+
/// </value>
49+
public Func<string> RunTimeString { get; set; }
4250
}
4351
}

src/NetCore2Blockly/NetCore2Blockly/ExtensionMethods/CLIExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public static void UseBlocklyUI(this IApplicationBuilder appBuilder, BlocklyUIOp
283283
data= options.CustomBlocks?.Replace("`", @"\`");
284284
str += $"{Environment.NewLine}var customBlocks = `{data}`;";
285285

286-
286+
str += $"{Environment.NewLine}{options.RunTimeString?.Invoke()};";
287287
var result = Encoding.UTF8.GetBytes(str);
288288
var m = new Memory<byte>(result);
289289
await cnt.Response.BodyWriter.WriteAsync(m);

src/NetCore2Blockly/NetCore2Blockly/NetCore2Blockly.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/NetCore2Blockly/TestBlocklyHtml/Startup.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,9 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
220220
{
221221
StartBlocks = StartBlocksForUI,
222222
HeaderName = "Demo test for .NET Core WebAPI To Blockly ( demo site with Blockly + swaggers + odata loaded + graphql)",
223-
CustomBlocks = CustomBlocksForUI
224-
});
223+
CustomBlocks = CustomBlocksForUI,
224+
RunTimeString = () => $"console.log('this is from runtime blocks {DateTime.Now.Ticks}');"
225+
});
225226

226227
app.UseBlocklyLocalStorage();
227228
//app.UseBlocklySqliteStorage();

0 commit comments

Comments
 (0)