Skip to content

Commit 35585e1

Browse files
committed
more configuration via runtimestring
1 parent 646010f commit 35585e1

6 files changed

Lines changed: 15 additions & 7 deletions

File tree

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ variables:
1010
solution: '**/*.sln'
1111
buildPlatform: 'Any CPU'
1212
buildConfiguration: 'Release'
13-
deployNuget: '0'
13+
deployNuget: '1'
1414

1515
steps:
1616
- task: NuGetToolInstaller@1

src/NetCore2Blockly/NetCore2Blockly/BlocklyUIOptions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using Microsoft.Extensions.Configuration;
2+
using System;
23
using System.Collections.Generic;
34
using System.Text;
45

@@ -46,6 +47,6 @@ public BlocklyUIOptions()
4647
/// <value>
4748
/// The run time blocks.
4849
/// </value>
49-
public Func<string> RunTimeString { get; set; }
50+
public Func<IServiceProvider, string> RunTimeString { get; set; }
5051
}
5152
}

src/NetCore2Blockly/NetCore2Blockly/ExtensionMethods/CLIExtension.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public static void UseBlocklyUI(this IApplicationBuilder appBuilder, BlocklyUIOp
267267
{
268268
var manifestEmbeddedProvider =
269269
new ManifestEmbeddedFileProvider(Assembly.GetExecutingAssembly());
270-
270+
var service = appBuilder.ApplicationServices;
271271
mapFile("blocklyFiles", manifestEmbeddedProvider, appBuilder);
272272

273273
#region map options
@@ -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-
str += $"{Environment.NewLine}{options.RunTimeString?.Invoke()};";
286+
str += $"{Environment.NewLine}{options.RunTimeString?.Invoke(service)};";
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: 1 addition & 1 deletion
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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,13 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
221221
StartBlocks = StartBlocksForUI,
222222
HeaderName = "Demo test for .NET Core WebAPI To Blockly ( demo site with Blockly + swaggers + odata loaded + graphql)",
223223
CustomBlocks = CustomBlocksForUI,
224-
RunTimeString = () => $"console.log('this is from runtime blocks {DateTime.Now.Ticks}');"
224+
RunTimeString = c =>
225+
{
226+
var str=$"console.log('this is from runtime blocks {DateTime.Now.Ticks}');";
227+
var val = c.GetRequiredService<IConfiguration>().GetSection("myCustomValue").Value;
228+
str += val;
229+
return str;
230+
}
225231
});
226232

227233
app.UseBlocklyLocalStorage();

src/NetCore2Blockly/TestBlocklyHtml/appsettings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
}
88
},
99
"AllowedHosts": "*",
10+
"myCustomValue": "console.log('this is from the appsettings at runtime - can be modified');",
1011
"NetCoreBlockly": {
1112
"OtherLinks": {
1213
"Swaggers": [

0 commit comments

Comments
 (0)