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 | 627 | 4/13/2022 |
11.1.0-dev.4 | 140 | 4/6/2022 |
11.1.0-dev.3 | 127 | 3/30/2022 |
11.1.0-dev.2 | 129 | 3/23/2022 |
11.1.0-dev.1 | 122 | 3/23/2022 |
11.0.0 | 515 | 3/11/2022 |
11.0.0-dev.7 | 137 | 3/7/2022 |
11.0.0-dev.6 | 131 | 2/28/2022 |
11.0.0-dev.5 | 131 | 2/26/2022 |
11.0.0-dev.4 | 138 | 2/24/2022 |
11.0.0-dev.3 | 133 | 2/23/2022 |
11.0.0-dev.2 | 132 | 2/18/2022 |
11.0.0-dev.1 | 135 | 2/7/2022 |
10.3.0 | 495 | 1/18/2022 |
10.2.0 | 859 | 12/3/2021 |
10.1.0 | 4,922 | 11/23/2021 |
10.1.0-dev.7 | 187 | 11/17/2021 |
10.1.0-dev.6 | 157 | 11/16/2021 |
10.1.0-dev.5 | 166 | 11/10/2021 |
10.1.0-dev.4 | 157 | 11/8/2021 |
10.1.0-dev.3 | 143 | 11/8/2021 |
10.1.0-dev.2 | 162 | 11/4/2021 |
10.1.0-dev.1 | 161 | 11/3/2021 |
10.0.1 | 436 | 10/16/2021 |
10.0.0 | 416 | 10/13/2021 |
10.0.0-dev.4 | 151 | 10/13/2021 |
10.0.0-dev.3 | 172 | 10/11/2021 |
10.0.0-dev.2 | 221 | 10/8/2021 |
9.3.4 | 392 | 8/25/2021 |
9.3.3 | 386 | 8/25/2021 |
9.3.2 | 404 | 8/24/2021 |
9.3.1 | 389 | 8/12/2021 |
9.3.0 | 422 | 8/12/2021 |
9.2.0 | 404 | 6/17/2021 |
9.1.0 | 420 | 6/17/2021 |
9.1.0-dev.9 | 197 | 5/26/2021 |
9.1.0-dev.8 | 185 | 5/26/2021 |
9.1.0-dev.7 | 191 | 5/17/2021 |
9.1.0-dev.6 | 181 | 4/28/2021 |
9.1.0-dev.5 | 188 | 4/23/2021 |
9.1.0-dev.4 | 195 | 4/21/2021 |
9.1.0-dev.3 | 186 | 4/17/2021 |
9.1.0-dev.2 | 183 | 4/12/2021 |
9.1.0-dev.1 | 244 | 4/9/2021 |
9.0.5 | 401 | 3/31/2021 |
9.0.4 | 444 | 3/23/2021 |
9.0.3 | 439 | 3/20/2021 |
9.0.1 | 399 | 3/18/2021 |
9.0.0 | 422 | 3/17/2021 |
9.0.0-dev.4 | 188 | 3/4/2021 |
9.0.0-dev.3 | 196 | 3/1/2021 |
9.0.0-dev.2 | 215 | 2/22/2021 |
8.4.0 | 454 | 11/11/2020 |
8.3.0 | 465 | 10/28/2020 |
8.2.0 | 544 | 10/16/2020 |
8.1.0 | 577 | 9/23/2020 |
8.0.0 | 515 | 7/1/2020 |
8.0.0-dev.44 | 296 | 6/25/2020 |
8.0.0-dev.43 | 283 | 6/23/2020 |
8.0.0-dev.42 | 309 | 6/22/2020 |
8.0.0-dev.41 | 299 | 6/18/2020 |
8.0.0-dev.40 | 272 | 6/18/2020 |
8.0.0-dev.39 | 289 | 6/15/2020 |
8.0.0-dev.38 | 397 | 6/14/2020 |
8.0.0-dev.37 | 257 | 6/13/2020 |
8.0.0-dev.36 | 305 | 6/13/2020 |
8.0.0-dev.35 | 246 | 6/12/2020 |
8.0.0-dev.34 | 295 | 6/12/2020 |
8.0.0-dev.33 | 336 | 6/10/2020 |
8.0.0-dev.32 | 264 | 6/1/2020 |
8.0.0-dev.31 | 285 | 6/1/2020 |
8.0.0-dev.30 | 357 | 5/30/2020 |
8.0.0-dev.28 | 299 | 5/28/2020 |
8.0.0-dev.27 | 279 | 5/15/2020 |
8.0.0-dev.26 | 258 | 5/14/2020 |
8.0.0-dev.25 | 287 | 5/14/2020 |
8.0.0-dev.24 | 275 | 5/13/2020 |
8.0.0-dev.23 | 280 | 5/13/2020 |
8.0.0-dev.22 | 276 | 5/13/2020 |
8.0.0-dev.21 | 269 | 5/12/2020 |
8.0.0-dev.20 | 274 | 5/12/2020 |
8.0.0-dev.19 | 285 | 5/7/2020 |
8.0.0-dev.18 | 275 | 5/7/2020 |
8.0.0-dev.17 | 274 | 5/6/2020 |
8.0.0-dev.16 | 267 | 5/6/2020 |
8.0.0-dev.15 | 269 | 5/5/2020 |
8.0.0-dev.14 | 267 | 5/5/2020 |
8.0.0-dev.13 | 294 | 5/4/2020 |
7.6.0-dev.13 | 298 | 5/1/2020 |
7.6.0-dev.12 | 302 | 4/30/2020 |
7.6.0-dev.11 | 268 | 4/28/2020 |
7.6.0-dev.10 | 268 | 4/27/2020 |
7.6.0-dev.9 | 261 | 4/24/2020 |
7.6.0-dev.8 | 271 | 4/22/2020 |
7.6.0-dev.7 | 265 | 4/15/2020 |
7.6.0-dev.6 | 261 | 4/15/2020 |
7.6.0-dev.5 | 253 | 4/15/2020 |
7.6.0-dev.4 | 381 | 4/11/2020 |
7.6.0-dev.3 | 260 | 4/10/2020 |
7.6.0-dev.2 | 252 | 4/10/2020 |
7.6.0-dev.1 | 333 | 4/8/2020 |
7.5.2 | 608 | 3/20/2020 |
7.5.1 | 530 | 3/12/2020 |
7.5.0 | 536 | 3/10/2020 |
7.5.0-dev.18 | 291 | 3/5/2020 |
7.5.0-dev.17 | 289 | 3/5/2020 |
7.5.0-dev.16 | 306 | 3/4/2020 |
7.5.0-dev.15 | 252 | 3/3/2020 |
7.5.0-dev.14 | 266 | 3/3/2020 |
7.5.0-dev.13 | 250 | 2/29/2020 |
7.5.0-dev.12 | 373 | 2/29/2020 |
7.5.0-dev.10 | 252 | 2/25/2020 |
7.5.0-dev.9 | 297 | 2/20/2020 |
7.5.0-dev.8 | 324 | 2/18/2020 |
7.5.0-dev.7 | 256 | 2/18/2020 |
7.5.0-dev.6 | 279 | 2/14/2020 |
7.5.0-dev.5 | 301 | 2/12/2020 |
7.5.0-dev.4 | 274 | 2/11/2020 |
7.5.0-dev.3 | 246 | 2/11/2020 |
7.5.0-dev.2 | 389 | 2/8/2020 |
7.5.0-dev.1 | 279 | 2/7/2020 |
7.4.2 | 527 | 2/5/2020 |
7.4.1 | 601 | 2/3/2020 |
7.4.0 | 610 | 1/31/2020 |
7.4.0-dev.4 | 329 | 1/31/2020 |
7.4.0-dev.3 | 306 | 1/29/2020 |
7.4.0-dev.2 | 261 | 1/28/2020 |
7.4.0-dev.1 | 253 | 1/23/2020 |
7.3.1 | 622 | 1/21/2020 |
7.3.1-preview.7 | 265 | 1/21/2020 |
7.3.1-preview.1 | 295 | 1/20/2020 |
7.3.0 | 524 | 1/19/2020 |
7.2.6 | 609 | 1/18/2020 |
7.2.5 | 566 | 12/19/2019 |
7.2.4 | 577 | 12/19/2019 |
7.2.3 | 579 | 12/16/2019 |
7.2.2 | 544 | 12/9/2019 |
7.2.1 | 566 | 12/4/2019 |
7.2.0 | 519 | 11/26/2019 |
7.2.0-preview.10 | 265 | 11/20/2019 |
7.2.0-preview.9 | 267 | 11/19/2019 |
7.2.0-preview.8 | 267 | 11/18/2019 |
7.2.0-preview.6 | 278 | 11/14/2019 |
7.2.0-preview.5 | 273 | 11/14/2019 |
7.2.0-preview.4 | 261 | 11/14/2019 |
7.2.0-preview.2 | 267 | 11/11/2019 |
7.2.0-preview.1 | 268 | 11/9/2019 |
7.1.0 | 566 | 11/6/2019 |
7.1.0-preview.8 | 275 | 11/5/2019 |
7.1.0-preview.7 | 272 | 11/4/2019 |
7.1.0-preview.6 | 270 | 11/1/2019 |
7.1.0-preview.5 | 289 | 10/31/2019 |
7.1.0-preview.4 | 290 | 10/30/2019 |
7.1.0-preview.3 | 275 | 10/26/2019 |
7.1.0-preview.2 | 273 | 10/25/2019 |
7.1.0-preview.1 | 273 | 10/24/2019 |
7.0.0 | 551 | 10/16/2019 |
7.0.0-rc.41 | 280 | 10/15/2019 |
7.0.0-rc.40 | 291 | 10/15/2019 |
7.0.0-rc.39 | 286 | 10/12/2019 |
7.0.0-rc.38 | 277 | 10/11/2019 |
7.0.0-rc.37 | 277 | 10/10/2019 |
7.0.0-rc.36 | 272 | 10/9/2019 |
7.0.0-rc.35 | 273 | 10/8/2019 |
7.0.0-rc.34 | 279 | 10/8/2019 |
7.0.0-rc.33 | 273 | 10/7/2019 |
7.0.0-rc.32 | 269 | 10/5/2019 |
7.0.0-rc.31 | 279 | 10/3/2019 |
7.0.0-rc.30 | 284 | 10/1/2019 |
7.0.0-rc.28 | 284 | 10/1/2019 |
7.0.0-rc.27 | 271 | 9/30/2019 |
7.0.0-rc.26 | 285 | 9/30/2019 |
7.0.0-rc.25 | 269 | 9/27/2019 |
7.0.0-rc.24 | 273 | 9/27/2019 |
7.0.0-rc.23 | 264 | 9/26/2019 |
7.0.0-rc.22 | 276 | 9/25/2019 |
7.0.0-rc.21 | 278 | 9/24/2019 |
7.0.0-rc.20 | 281 | 9/23/2019 |
7.0.0-rc.19 | 271 | 9/20/2019 |
7.0.0-rc.18.1 | 275 | 9/20/2019 |
7.0.0-rc.18 | 282 | 9/20/2019 |
6.5.0-rc.17 | 292 | 9/19/2019 |
6.5.0-rc.16 | 295 | 9/18/2019 |
6.5.0-rc.15 | 295 | 9/18/2019 |
6.5.0-rc.14.1 | 297 | 9/18/2019 |
6.5.0-rc.14 | 291 | 9/17/2019 |
6.5.0-rc.13 | 288 | 9/16/2019 |
6.5.0-rc.12.2 | 289 | 9/13/2019 |
6.5.0-rc.12.1 | 293 | 9/12/2019 |
6.5.0-rc.12 | 292 | 9/12/2019 |
6.5.0-rc.11 | 290 | 9/11/2019 |
6.5.0-rc.10 | 288 | 9/10/2019 |
6.5.0-rc.9 | 284 | 9/9/2019 |
6.5.0-rc.8 | 281 | 9/6/2019 |
6.5.0-rc.7 | 291 | 9/6/2019 |
6.5.0-rc.6 | 291 | 9/6/2019 |
6.5.0-rc.5 | 284 | 9/2/2019 |
6.5.0-rc.4 | 290 | 9/2/2019 |
6.5.0-rc.3 | 279 | 8/30/2019 |
6.5.0-rc.2 | 307 | 8/29/2019 |
6.5.0-rc.1 | 295 | 8/28/2019 |
6.5.0-beta.5 | 298 | 8/28/2019 |
6.5.0-beta.4 | 296 | 8/27/2019 |
6.0.0 | 611 | 8/6/2019 |
6.0.0-rc.7 | 285 | 7/19/2019 |
6.0.0-rc.6 | 295 | 6/28/2019 |
6.0.0-rc.5 | 283 | 6/28/2019 |
6.0.0-rc.4 | 285 | 6/25/2019 |
6.0.0-rc.3 | 298 | 6/20/2019 |
6.0.0-rc.2 | 292 | 5/29/2019 |
6.0.0-rc.1 | 294 | 5/28/2019 |
6.0.0-beta.3 | 305 | 4/17/2019 |
5.3.0-beta.2 | 299 | 3/21/2019 |
5.3.0-beta.1 | 295 | 3/20/2019 |
5.2.0 | 599 | 3/19/2019 |
5.1.0 | 889 | 1/25/2019 |
5.0.0 | 940 | 12/21/2018 |
5.0.0-rc11 | 704 | 12/14/2018 |
5.0.0-rc10 | 577 | 11/16/2018 |
5.0.0-rc09 | 572 | 11/1/2018 |
5.0.0-rc08 | 538 | 10/31/2018 |
5.0.0-rc07 | 577 | 10/31/2018 |
5.0.0-rc06 | 578 | 10/30/2018 |
5.0.0-rc05 | 572 | 10/29/2018 |
5.0.0-rc04 | 603 | 10/29/2018 |
5.0.0-rc03 | 587 | 10/26/2018 |
5.0.0-rc02 | 578 | 10/25/2018 |
5.0.0-rc01 | 612 | 10/12/2018 |
5.0.0-beta03 | 620 | 9/21/2018 |
5.0.0-beta02 | 626 | 9/10/2018 |
5.0.0-beta01 | 627 | 9/7/2018 |
4.5.1 | 917 | 8/7/2018 |
4.5.0 | 893 | 8/7/2018 |
4.5.0-rc01 | 758 | 6/7/2018 |
4.5.0-beta09 | 756 | 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.