added custom blocks · ignatandrei/NETCoreBlockly@b027743 · GitHub
Skip to content

Commit b027743

Browse files
committed
added custom blocks
1 parent f9cada0 commit b027743

6 files changed

Lines changed: 124 additions & 5 deletions

File tree

‎azure-pipelines.yml‎

Lines changed: 1 addition & 1 deletion

‎src/NetCore2Blockly/NetCore2Blockly/BlocklyUIOptions.cs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,13 @@ public BlocklyUIOptions()
3131
/// The name.
3232
/// </value>
3333
public string HeaderName { get; set; }
34+
35+
/// <summary>
36+
/// Gets or sets the custom blocks.
37+
/// </summary>
38+
/// <value>
39+
/// The custom blocks.
40+
/// </value>
41+
public string CustomBlocks { get; set; }
3442
}
3543
}

‎src/NetCore2Blockly/NetCore2Blockly/ExtensionMethods/CLIExtension.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,10 @@ public static void UseBlocklyUI(this IApplicationBuilder appBuilder, BlocklyUIOp
266266
var str = $"var startBlocksStr=`{data}`;";
267267
data = options.HeaderName?.Replace("`", @"\`");
268268
str += $"{Environment.NewLine}var optHeaderName = `{data}`;";
269+
data= options.CustomBlocks?.Replace("`", @"\`");
270+
str += $"{Environment.NewLine}var customBlocks = `{data}`;";
271+
272+
269273
var result = Encoding.UTF8.GetBytes(str);
270274
var m = new Memory<byte>(result);
271275
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: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
211211
app.UseBlocklyUI(new BlocklyUIOptions()
212212
{
213213
StartBlocks = StartBlocksForUI,
214-
HeaderName = "Demo test for .NET Core WebAPI ( site with Blockly + swaggers + odata loaded + graphql)"
214+
HeaderName = "Demo test for .NET Core WebAPI ( site with Blockly + swaggers + odata loaded + graphql)",
215+
CustomBlocks = CustomBlocksForUI
215216
});
216217

217218
app.UseBlocklyLocalStorage();
@@ -353,5 +354,97 @@ private IEdmModel ModelDB()
353354
</next>
354355
</block>
355356
</xml>";
357+
private readonly string CustomBlocksForUI = @"
358+
<category name='UserDefinedBlocks'>
359+
<category name='Database'>
360+
361+
<block type='procedures_defreturn' x='97' y='25'>
362+
<mutation>
363+
<arg name='NameDepartment' varid='iyUw;Eri3EKdpA#7(]cT'></arg>
364+
</mutation>
365+
<field name='NAME'>FindEmployees</field>
366+
<comment pinned='true' h='80' w='160'>Find all employees from department</comment>
367+
<statement name='STACK'>
368+
<block type='variables_set'>
369+
<field name='VAR' id='hO`?kR*XbVn|uJq:?jJ_'>N</field>
370+
<value name='VALUE'>
371+
<block type='api_VariousTests_GetDepartment__name__GET'>
372+
<value name='val_name'>
373+
<shadow type='text'>
374+
<field name='TEXT'>IT</field>
375+
</shadow>
376+
<block type='variables_get'>
377+
<field name='VAR' id='iyUw;Eri3EKdpA#7(]cT'>NameDepartment</field>
378+
</block>
379+
</value>
380+
</block>
381+
</value>
382+
<next>
383+
<block type='variables_set'>
384+
<field name='VAR' id='hO`?kR*XbVn|uJq:?jJ_'>N</field>
385+
<value name='VALUE'>
386+
<block type='converttojson'>
387+
<value name='ValueToConvert'>
388+
<block type='variables_get'>
389+
<field name='VAR' id='hO`?kR*XbVn|uJq:?jJ_'>N</field>
390+
</block>
391+
</value>
392+
</block>
393+
</value>
394+
<next>
395+
<block type='variables_set'>
396+
<field name='VAR' id='hO`?kR*XbVn|uJq:?jJ_'>N</field>
397+
<value name='VALUE'>
398+
<block type='getproperty'>
399+
<field name='objectName'>object</field>
400+
<field name='prop'>property</field>
401+
<value name='ObjectToChange'>
402+
<block type='variables_get'>
403+
<field name='VAR' id='hO`?kR*XbVn|uJq:?jJ_'>N</field>
404+
</block>
405+
</value>
406+
<value name='PropertyName'>
407+
<block type='text'>
408+
<field name='TEXT'>employee</field>
409+
</block>
410+
</value>
411+
</block>
412+
</value>
413+
</block>
414+
</next>
415+
</block>
416+
</next>
417+
</block>
418+
</statement>
419+
<value name='RETURN'>
420+
<block type='converttostring'>
421+
<value name='ValueToConvert'>
422+
<block type='variables_get'>
423+
<field name='VAR' id='hO`?kR*XbVn|uJq:?jJ_'>N</field>
424+
</block>
425+
</value>
426+
</block>
427+
</value>
428+
</block>
429+
<block type='text_print' x='105' y='293'>
430+
<value name='TEXT'>
431+
<shadow type='text'>
432+
<field name='TEXT'>abc</field>
433+
</shadow>
434+
<block type='procedures_callreturn'>
435+
<mutation name='FindEmployees'>
436+
<arg name='NameDepartment'></arg>
437+
</mutation>
438+
<value name='ARG0'>
439+
<block type='text'>
440+
<field name='TEXT'>IT</field>
441+
</block>
442+
</value>
443+
</block>
444+
</value>
445+
</block>
446+
</category>
447+
</category>
448+
";
356449
}
357450
}

‎src/NetCore2Blockly/TestBlocklyHtml/wwwroot/blockly.html‎

Lines changed: 9 additions & 3 deletions

0 commit comments

Comments
 (0)