Kephas.Scripting.CSharp
11.0.0-dev.4
Prefix Reserved
See the version list below for details.
dotnet add package Kephas.Scripting.CSharp --version 11.0.0-dev.4
NuGet\Install-Package Kephas.Scripting.CSharp -Version 11.0.0-dev.4
<PackageReference Include="Kephas.Scripting.CSharp" Version="11.0.0-dev.4" />
paket add Kephas.Scripting.CSharp --version 11.0.0-dev.4
#r "nuget: Kephas.Scripting.CSharp, 11.0.0-dev.4"
// Install Kephas.Scripting.CSharp as a Cake Addin #addin nuget:?package=Kephas.Scripting.CSharp&version=11.0.0-dev.4&prerelease // Install Kephas.Scripting.CSharp as a Cake Tool #tool nuget:?package=Kephas.Scripting.CSharp&version=11.0.0-dev.4&prerelease
Templating
Introduction
The scripting area in Kephas handles dynamic code execution.
The entry point is the IScriptProcessor
singleton service, which returns a result through the ExecuteAsync
method, provided with a script, execution arguments, and globals.
Usage
// normally you would get the processor injected into the service constructor.
var processor = injector.Resolve<IScriptProcessor>();
// the next line uses C# scripting, so you will need also to reference Kephas.Scripting.CSharp.
var result = processor.ExecuteAsync(new CSharpStringScript("name[..4] + age.ToString()"), new { name = "Johnny", age = 42 }));
Assert.Equals("John42", result);
// the next line uses Python scripting, so you will need also to reference Kephas.Scripting.Python.
var result = processor.ExecuteAsync(new PythonStringScript("name[..4] + str(age)"), new Expando { ["name"] = "Johnny", ["age"] = 42 }));
Assert.Equals("John42", result);
The ITemplateProcessor
service
This service is the central piece providing the ProcessAsync
method through which a template is processed.
Typically, the output is written to the ITemplateProcessingContext.TextWriter
, but, if this is not set by the user,
it is the duty of the template processor to prepare the TextWriter
and to return in the operation result
the result returned by the processing engine.
DefaultTemplateProcessor
is the default implementation of the ITemplateProcessor
.
Just like the other default implementations provided by the Kephas framework, it declares a low override priority, so that it can be easily overridden.
By default, it delegates the template processing to a specific ITemplatingEngine
handling the provided template.
It identifies the engine based on the template's kind, which the engine declares using the [TemplateKind(...)]
attribute.
Template engines
These services implement the ITemplatingEngine
contract and handle specific template kinds.
By default, the framework provides the InterpolationTemplatingEngine
which handles simple string interpolations using the curly braces pattern: {variable}
. All such variables are replaced with the values of the properties' with the same name in the model.
Controlling the template processing
The processing context
Additional to the template and the model, the processing methods receive also a context which can be used to further control the operations.
Just like all the other context instances, it is a dynamic expandable object (IExpando
) and it aggregates the provided template and the model.
Through the Result
and Exception
properties, the behaviors (see below) can control the processing output.
The processing behaviors
The DefaultTemplateProcessor
uses also ITemplateProcessing
behavior services to further control the processing. Just like the ITemplateEngine
services, they declare the template kinds they handle,
and are invoked before and after the selected engine processes the template. They can cover various purposes: authorization, pre-processing/post-processing, audit, and whatever other functionality may be required.
The templates
A template implements ITemplate
, basically providing a Kind
(string), a Name
(string), and an asynchronous content (GetContentAsync()
).
By default, the framework supports these templates:
StringTemplate
: constructed using a string. If theKind
is not provided,'interpolation'
is considered instead.StringBuilderTemplate
: constructed using aStringBuilder
. If theKind
is not provided,'interpolation'
is considered instead.StreamTemplate
: constructed using aStream
. If theKind
is not provided,'interpolation'
is considered instead.FileTemplate
: constructed using a file path. If theKind
is not provided, the file extension is considered instead.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Kephas.Scripting (>= 11.0.0-dev.4)
- Microsoft.CodeAnalysis.CSharp.Scripting (>= 4.1.0)
-
net6.0
- Kephas.Scripting (>= 11.0.0-dev.4)
- Microsoft.CodeAnalysis.CSharp.Scripting (>= 4.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
11.1.0 | 628 | 4/13/2022 |
11.1.0-dev.4 | 141 | 4/6/2022 |
11.1.0-dev.3 | 128 | 3/30/2022 |
11.1.0-dev.2 | 130 | 3/23/2022 |
11.1.0-dev.1 | 123 | 3/23/2022 |
11.0.0 | 516 | 3/11/2022 |
11.0.0-dev.7 | 138 | 3/7/2022 |
11.0.0-dev.6 | 132 | 2/28/2022 |
11.0.0-dev.5 | 132 | 2/26/2022 |
11.0.0-dev.4 | 139 | 2/24/2022 |
11.0.0-dev.3 | 134 | 2/23/2022 |
11.0.0-dev.2 | 133 | 2/18/2022 |
11.0.0-dev.1 | 138 | 2/7/2022 |
10.3.0 | 496 | 1/18/2022 |
10.2.0 | 860 | 12/3/2021 |
10.1.0 | 4,923 | 11/23/2021 |
10.1.0-dev.7 | 188 | 11/17/2021 |
10.1.0-dev.6 | 158 | 11/16/2021 |
10.1.0-dev.5 | 167 | 11/10/2021 |
10.1.0-dev.4 | 158 | 11/8/2021 |
10.1.0-dev.3 | 144 | 11/8/2021 |
10.1.0-dev.2 | 163 | 11/4/2021 |
10.1.0-dev.1 | 162 | 11/3/2021 |
10.0.1 | 437 | 10/16/2021 |
10.0.0 | 417 | 10/13/2021 |
10.0.0-dev.4 | 152 | 10/13/2021 |
10.0.0-dev.3 | 173 | 10/11/2021 |
10.0.0-dev.2 | 222 | 10/8/2021 |
9.3.4 | 395 | 8/25/2021 |
9.3.3 | 387 | 8/25/2021 |
9.3.2 | 405 | 8/24/2021 |
9.3.1 | 392 | 8/12/2021 |
9.3.0 | 423 | 8/12/2021 |
9.2.0 | 405 | 6/17/2021 |
9.1.0 | 421 | 6/17/2021 |
9.1.0-dev.9 | 198 | 5/26/2021 |
9.1.0-dev.8 | 186 | 5/26/2021 |
9.1.0-dev.7 | 192 | 5/17/2021 |
9.1.0-dev.6 | 182 | 4/28/2021 |
9.1.0-dev.5 | 189 | 4/23/2021 |
9.1.0-dev.4 | 196 | 4/21/2021 |
9.1.0-dev.3 | 187 | 4/17/2021 |
9.1.0-dev.2 | 184 | 4/12/2021 |
9.1.0-dev.1 | 245 | 4/9/2021 |
9.0.5 | 402 | 3/31/2021 |
9.0.4 | 447 | 3/23/2021 |
9.0.3 | 440 | 3/20/2021 |
9.0.1 | 400 | 3/18/2021 |
9.0.0 | 423 | 3/17/2021 |
9.0.0-dev.4 | 189 | 3/4/2021 |
9.0.0-dev.3 | 197 | 3/1/2021 |
9.0.0-dev.2 | 216 | 2/22/2021 |
8.4.0 | 455 | 11/11/2020 |
8.3.0 | 466 | 10/28/2020 |
8.2.0 | 545 | 10/16/2020 |
8.1.0 | 578 | 9/23/2020 |
8.0.0 | 516 | 7/1/2020 |
8.0.0-dev.44 | 297 | 6/25/2020 |
8.0.0-dev.43 | 284 | 6/23/2020 |
8.0.0-dev.42 | 310 | 6/22/2020 |
8.0.0-dev.41 | 300 | 6/18/2020 |
8.0.0-dev.40 | 273 | 6/18/2020 |
8.0.0-dev.39 | 290 | 6/15/2020 |
8.0.0-dev.38 | 398 | 6/14/2020 |
8.0.0-dev.37 | 258 | 6/13/2020 |
8.0.0-dev.36 | 306 | 6/13/2020 |
8.0.0-dev.35 | 247 | 6/12/2020 |
8.0.0-dev.34 | 296 | 6/12/2020 |
8.0.0-dev.33 | 337 | 6/10/2020 |
8.0.0-dev.32 | 265 | 6/1/2020 |
8.0.0-dev.31 | 286 | 6/1/2020 |
8.0.0-dev.30 | 358 | 5/30/2020 |
8.0.0-dev.28 | 300 | 5/28/2020 |
8.0.0-dev.27 | 280 | 5/15/2020 |
8.0.0-dev.26 | 259 | 5/14/2020 |
8.0.0-dev.25 | 288 | 5/14/2020 |
8.0.0-dev.24 | 276 | 5/13/2020 |
8.0.0-dev.23 | 281 | 5/13/2020 |
8.0.0-dev.22 | 277 | 5/13/2020 |
8.0.0-dev.21 | 270 | 5/12/2020 |
8.0.0-dev.20 | 275 | 5/12/2020 |
8.0.0-dev.19 | 286 | 5/7/2020 |
8.0.0-dev.18 | 276 | 5/7/2020 |
8.0.0-dev.17 | 275 | 5/6/2020 |
8.0.0-dev.16 | 268 | 5/6/2020 |
8.0.0-dev.15 | 270 | 5/5/2020 |
8.0.0-dev.14 | 268 | 5/5/2020 |
8.0.0-dev.13 | 295 | 5/4/2020 |
7.6.0-dev.13 | 299 | 5/1/2020 |
7.6.0-dev.12 | 303 | 4/30/2020 |
7.6.0-dev.11 | 269 | 4/28/2020 |
7.6.0-dev.10 | 269 | 4/27/2020 |
7.6.0-dev.9 | 262 | 4/24/2020 |
7.6.0-dev.8 | 272 | 4/22/2020 |
7.6.0-dev.7 | 266 | 4/15/2020 |
7.6.0-dev.6 | 262 | 4/15/2020 |
7.6.0-dev.5 | 254 | 4/15/2020 |
7.6.0-dev.4 | 382 | 4/11/2020 |
7.6.0-dev.3 | 261 | 4/10/2020 |
7.6.0-dev.2 | 253 | 4/10/2020 |
7.6.0-dev.1 | 334 | 4/8/2020 |
7.5.2 | 609 | 3/20/2020 |
7.5.1 | 531 | 3/12/2020 |
7.5.0 | 537 | 3/10/2020 |
7.5.0-dev.18 | 292 | 3/5/2020 |
7.5.0-dev.17 | 290 | 3/5/2020 |
7.5.0-dev.16 | 307 | 3/4/2020 |
7.5.0-dev.15 | 253 | 3/3/2020 |
7.5.0-dev.14 | 267 | 3/3/2020 |
7.5.0-dev.13 | 251 | 2/29/2020 |
7.5.0-dev.12 | 374 | 2/29/2020 |
7.5.0-dev.10 | 253 | 2/25/2020 |
7.5.0-dev.9 | 298 | 2/20/2020 |
7.5.0-dev.8 | 325 | 2/18/2020 |
7.5.0-dev.7 | 257 | 2/18/2020 |
7.5.0-dev.6 | 280 | 2/14/2020 |
7.5.0-dev.5 | 302 | 2/12/2020 |
7.5.0-dev.4 | 275 | 2/11/2020 |
7.5.0-dev.3 | 247 | 2/11/2020 |
7.5.0-dev.2 | 390 | 2/8/2020 |
7.5.0-dev.1 | 280 | 2/7/2020 |
7.4.2 | 528 | 2/5/2020 |
7.4.1 | 602 | 2/3/2020 |
7.4.0 | 611 | 1/31/2020 |
7.4.0-dev.4 | 330 | 1/31/2020 |
7.4.0-dev.3 | 307 | 1/29/2020 |
7.4.0-dev.2 | 262 | 1/28/2020 |
7.4.0-dev.1 | 254 | 1/23/2020 |
7.3.1 | 623 | 1/21/2020 |
7.3.1-preview.7 | 266 | 1/21/2020 |
7.3.1-preview.1 | 296 | 1/20/2020 |
7.3.0 | 525 | 1/19/2020 |
7.2.6 | 610 | 1/18/2020 |
7.2.5 | 567 | 12/19/2019 |
7.2.4 | 578 | 12/19/2019 |
7.2.3 | 580 | 12/16/2019 |
7.2.2 | 545 | 12/9/2019 |
7.2.1 | 567 | 12/4/2019 |
7.2.0 | 520 | 11/26/2019 |
7.2.0-preview.10 | 266 | 11/20/2019 |
7.2.0-preview.9 | 268 | 11/19/2019 |
7.2.0-preview.8 | 268 | 11/18/2019 |
7.2.0-preview.6 | 279 | 11/14/2019 |
7.2.0-preview.5 | 274 | 11/14/2019 |
7.2.0-preview.4 | 262 | 11/14/2019 |
7.2.0-preview.2 | 268 | 11/11/2019 |
7.2.0-preview.1 | 269 | 11/9/2019 |
7.1.0 | 567 | 11/6/2019 |
7.1.0-preview.8 | 276 | 11/5/2019 |
7.1.0-preview.7 | 273 | 11/4/2019 |
7.1.0-preview.6 | 271 | 11/1/2019 |
7.1.0-preview.5 | 290 | 10/31/2019 |
7.1.0-preview.4 | 291 | 10/30/2019 |
7.1.0-preview.3 | 276 | 10/26/2019 |
7.1.0-preview.2 | 274 | 10/25/2019 |
7.1.0-preview.1 | 274 | 10/24/2019 |
7.0.0 | 552 | 10/16/2019 |
7.0.0-rc.41 | 281 | 10/15/2019 |
7.0.0-rc.40 | 292 | 10/15/2019 |
7.0.0-rc.39 | 287 | 10/12/2019 |
7.0.0-rc.38 | 278 | 10/11/2019 |
7.0.0-rc.37 | 278 | 10/10/2019 |
7.0.0-rc.36 | 273 | 10/9/2019 |
7.0.0-rc.35 | 274 | 10/8/2019 |
7.0.0-rc.34 | 280 | 10/8/2019 |
7.0.0-rc.33 | 274 | 10/7/2019 |
7.0.0-rc.32 | 270 | 10/5/2019 |
7.0.0-rc.31 | 280 | 10/3/2019 |
7.0.0-rc.30 | 285 | 10/1/2019 |
7.0.0-rc.28 | 285 | 10/1/2019 |
7.0.0-rc.27 | 272 | 9/30/2019 |
7.0.0-rc.26 | 286 | 9/30/2019 |
7.0.0-rc.25 | 270 | 9/27/2019 |
7.0.0-rc.24 | 274 | 9/27/2019 |
7.0.0-rc.23 | 265 | 9/26/2019 |
7.0.0-rc.22 | 277 | 9/25/2019 |
7.0.0-rc.21 | 279 | 9/24/2019 |
7.0.0-rc.20 | 282 | 9/23/2019 |
7.0.0-rc.19 | 272 | 9/20/2019 |
7.0.0-rc.18.1 | 276 | 9/20/2019 |
7.0.0-rc.18 | 283 | 9/20/2019 |
6.5.0-rc.17 | 293 | 9/19/2019 |
6.5.0-rc.16 | 296 | 9/18/2019 |
6.5.0-rc.15 | 296 | 9/18/2019 |
6.5.0-rc.14.1 | 298 | 9/18/2019 |
6.5.0-rc.14 | 292 | 9/17/2019 |
6.5.0-rc.13 | 289 | 9/16/2019 |
6.5.0-rc.12.2 | 290 | 9/13/2019 |
6.5.0-rc.12.1 | 294 | 9/12/2019 |
6.5.0-rc.12 | 293 | 9/12/2019 |
6.5.0-rc.11 | 291 | 9/11/2019 |
6.5.0-rc.10 | 289 | 9/10/2019 |
6.5.0-rc.9 | 285 | 9/9/2019 |
6.5.0-rc.8 | 282 | 9/6/2019 |
6.5.0-rc.7 | 292 | 9/6/2019 |
6.5.0-rc.6 | 292 | 9/6/2019 |
6.5.0-rc.5 | 285 | 9/2/2019 |
6.5.0-rc.4 | 291 | 9/2/2019 |
6.5.0-rc.3 | 280 | 8/30/2019 |
6.5.0-rc.2 | 310 | 8/29/2019 |
6.5.0-rc.1 | 296 | 8/28/2019 |
6.5.0-beta.5 | 299 | 8/28/2019 |
6.5.0-beta.4 | 297 | 8/27/2019 |
6.0.0 | 612 | 8/6/2019 |
6.0.0-rc.7 | 286 | 7/19/2019 |
6.0.0-rc.6 | 296 | 6/28/2019 |
6.0.0-rc.5 | 284 | 6/28/2019 |
6.0.0-rc.4 | 286 | 6/25/2019 |
6.0.0-rc.3 | 299 | 6/20/2019 |
6.0.0-rc.2 | 293 | 5/29/2019 |
6.0.0-rc.1 | 295 | 5/28/2019 |
6.0.0-beta.3 | 306 | 4/17/2019 |
5.3.0-beta.2 | 300 | 3/21/2019 |
5.3.0-beta.1 | 296 | 3/20/2019 |
5.2.0 | 600 | 3/19/2019 |
5.1.0 | 890 | 1/25/2019 |
5.0.0 | 941 | 12/21/2018 |
5.0.0-rc11 | 707 | 12/14/2018 |
5.0.0-rc10 | 578 | 11/16/2018 |
5.0.0-rc09 | 573 | 11/1/2018 |
5.0.0-rc08 | 539 | 10/31/2018 |
5.0.0-rc07 | 578 | 10/31/2018 |
5.0.0-rc06 | 579 | 10/30/2018 |
5.0.0-rc05 | 573 | 10/29/2018 |
5.0.0-rc04 | 606 | 10/29/2018 |
5.0.0-rc03 | 588 | 10/26/2018 |
5.0.0-rc02 | 579 | 10/25/2018 |
5.0.0-rc01 | 614 | 10/12/2018 |
5.0.0-beta03 | 622 | 9/21/2018 |
5.0.0-beta02 | 628 | 9/10/2018 |
5.0.0-beta01 | 629 | 9/7/2018 |
4.5.1 | 918 | 8/7/2018 |
4.5.0 | 894 | 8/7/2018 |
4.5.0-rc01 | 759 | 6/7/2018 |
4.5.0-beta09 | 757 | 6/7/2018 |
Please check https://github.com/kephas-software/kephas/releases for the change log.
Also check the documentation and the samples from https://github.com/kephas-software/kephas/wiki and https://github.com/kephas-software/kephas/tree/master/Samples.