Kephas.Scripting.CSharp 11.0.0-dev.4

Prefix Reserved
This is a prerelease version of Kephas.Scripting.CSharp.
There is a newer version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Kephas.Scripting.CSharp" Version="11.0.0-dev.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Kephas.Scripting.CSharp" Version="11.0.0-dev.4" />
                    
Directory.Packages.props
<PackageReference Include="Kephas.Scripting.CSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Kephas.Scripting.CSharp --version 11.0.0-dev.4
                    
#r "nuget: Kephas.Scripting.CSharp, 11.0.0-dev.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Kephas.Scripting.CSharp@11.0.0-dev.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Kephas.Scripting.CSharp&version=11.0.0-dev.4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Kephas.Scripting.CSharp&version=11.0.0-dev.4&prerelease
                    
Install as a Cake Tool

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 the Kind is not provided, 'interpolation' is considered instead.
  • StringBuilderTemplate: constructed using a StringBuilder. If the Kind is not provided, 'interpolation' is considered instead.
  • StreamTemplate: constructed using a Stream. If the Kind is not provided, 'interpolation' is considered instead.
  • FileTemplate: constructed using a file path. If the Kind is not provided, the file extension is considered instead.
Product 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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 867 4/13/2022
11.1.0-dev.4 264 4/6/2022
11.1.0-dev.3 248 3/30/2022
11.1.0-dev.2 255 3/23/2022
11.1.0-dev.1 247 3/23/2022
11.0.0 665 3/11/2022
11.0.0-dev.7 259 3/7/2022
11.0.0-dev.6 273 2/28/2022
11.0.0-dev.5 270 2/26/2022
11.0.0-dev.4 270 2/24/2022
11.0.0-dev.3 271 2/23/2022
11.0.0-dev.2 267 2/18/2022
11.0.0-dev.1 271 2/7/2022
10.3.0 648 1/18/2022
10.2.0 1,013 12/3/2021
10.1.0 5,082 11/23/2021
10.1.0-dev.7 322 11/17/2021
10.1.0-dev.6 295 11/16/2021
10.1.0-dev.5 300 11/10/2021
10.1.0-dev.4 285 11/8/2021
10.1.0-dev.3 276 11/8/2021
10.1.0-dev.2 302 11/4/2021
10.1.0-dev.1 289 11/3/2021
10.0.1 605 10/16/2021
10.0.0 572 10/13/2021
10.0.0-dev.4 286 10/13/2021
10.0.0-dev.3 300 10/11/2021
10.0.0-dev.2 354 10/8/2021
9.3.4 555 8/25/2021
9.3.3 544 8/25/2021
9.3.2 556 8/24/2021
9.3.1 550 8/12/2021
9.3.0 579 8/12/2021
9.2.0 551 6/17/2021
9.1.0 578 6/17/2021
9.1.0-dev.9 334 5/26/2021
9.1.0-dev.8 316 5/26/2021
9.1.0-dev.7 328 5/17/2021
9.1.0-dev.6 319 4/28/2021
9.1.0-dev.5 327 4/23/2021
9.1.0-dev.4 332 4/21/2021
9.1.0-dev.3 323 4/17/2021
9.1.0-dev.2 320 4/12/2021
9.1.0-dev.1 386 4/9/2021
9.0.5 563 3/31/2021
9.0.4 596 3/23/2021
9.0.3 611 3/20/2021
9.0.1 579 3/18/2021
9.0.0 594 3/17/2021
9.0.0-dev.4 333 3/4/2021
9.0.0-dev.3 342 3/1/2021
9.0.0-dev.2 364 2/22/2021
8.4.0 634 11/11/2020
8.3.0 646 10/28/2020
8.2.0 723 10/16/2020
8.1.0 764 9/23/2020
8.0.0 700 7/1/2020
8.0.0-dev.44 451 6/25/2020
8.0.0-dev.43 444 6/23/2020
8.0.0-dev.42 463 6/22/2020
8.0.0-dev.41 464 6/18/2020
8.0.0-dev.40 433 6/18/2020
8.0.0-dev.39 445 6/15/2020
8.0.0-dev.38 557 6/14/2020
8.0.0-dev.37 422 6/13/2020
8.0.0-dev.36 468 6/13/2020
8.0.0-dev.35 403 6/12/2020
8.0.0-dev.34 444 6/12/2020
8.0.0-dev.33 496 6/10/2020
8.0.0-dev.32 420 6/1/2020
8.0.0-dev.31 438 6/1/2020
8.0.0-dev.30 513 5/30/2020
8.0.0-dev.28 454 5/28/2020
8.0.0-dev.27 445 5/15/2020
8.0.0-dev.26 423 5/14/2020
8.0.0-dev.25 445 5/14/2020
8.0.0-dev.24 438 5/13/2020
8.0.0-dev.23 439 5/13/2020
8.0.0-dev.22 442 5/13/2020
8.0.0-dev.21 437 5/12/2020
8.0.0-dev.20 436 5/12/2020
8.0.0-dev.19 442 5/7/2020
8.0.0-dev.18 443 5/7/2020
8.0.0-dev.17 442 5/6/2020
8.0.0-dev.16 435 5/6/2020
8.0.0-dev.15 431 5/5/2020
8.0.0-dev.14 433 5/5/2020
8.0.0-dev.13 459 5/4/2020
7.6.0-dev.13 461 5/1/2020
7.6.0-dev.12 461 4/30/2020
7.6.0-dev.11 425 4/28/2020
7.6.0-dev.10 434 4/27/2020
7.6.0-dev.9 418 4/24/2020
7.6.0-dev.8 436 4/22/2020
7.6.0-dev.7 430 4/15/2020
7.6.0-dev.6 422 4/15/2020
7.6.0-dev.5 428 4/15/2020
7.6.0-dev.4 547 4/11/2020
7.6.0-dev.3 425 4/10/2020
7.6.0-dev.2 415 4/10/2020
7.6.0-dev.1 494 4/8/2020
7.5.2 777 3/20/2020
7.5.1 716 3/12/2020
7.5.0 728 3/10/2020
7.5.0-dev.18 456 3/5/2020
7.5.0-dev.17 463 3/5/2020
7.5.0-dev.16 470 3/4/2020
7.5.0-dev.15 414 3/3/2020
7.5.0-dev.14 427 3/3/2020
7.5.0-dev.13 423 2/29/2020
7.5.0-dev.12 536 2/29/2020
7.5.0-dev.10 413 2/25/2020
7.5.0-dev.9 466 2/20/2020
7.5.0-dev.8 484 2/18/2020
7.5.0-dev.7 424 2/18/2020
7.5.0-dev.6 439 2/14/2020
7.5.0-dev.5 480 2/12/2020
7.5.0-dev.4 430 2/11/2020
7.5.0-dev.3 419 2/11/2020
7.5.0-dev.2 554 2/8/2020
7.5.0-dev.1 443 2/7/2020
7.4.2 716 2/5/2020
7.4.1 791 2/3/2020
7.4.0 795 1/31/2020
7.4.0-dev.4 488 1/31/2020
7.4.0-dev.3 468 1/29/2020
7.4.0-dev.2 422 1/28/2020
7.4.0-dev.1 415 1/23/2020
7.3.1 818 1/21/2020
7.3.1-preview.7 427 1/21/2020
7.3.1-preview.1 456 1/20/2020
7.3.0 720 1/19/2020
7.2.6 795 1/18/2020
7.2.5 751 12/19/2019
7.2.4 764 12/19/2019
7.2.3 767 12/16/2019
7.2.2 730 12/9/2019
7.2.1 755 12/4/2019
7.2.0 705 11/26/2019
7.2.0-preview.10 425 11/20/2019
7.2.0-preview.9 430 11/19/2019
7.2.0-preview.8 429 11/18/2019
7.2.0-preview.6 448 11/14/2019
7.2.0-preview.5 442 11/14/2019
7.2.0-preview.4 428 11/14/2019
7.2.0-preview.2 429 11/11/2019
7.2.0-preview.1 428 11/9/2019
7.1.0 753 11/6/2019
7.1.0-preview.8 441 11/5/2019
7.1.0-preview.7 433 11/4/2019
7.1.0-preview.6 432 11/1/2019
7.1.0-preview.5 452 10/31/2019
7.1.0-preview.4 451 10/30/2019
7.1.0-preview.3 440 10/26/2019
7.1.0-preview.2 448 10/25/2019
7.1.0-preview.1 440 10/24/2019
7.0.0 731 10/16/2019
7.0.0-rc.41 447 10/15/2019
7.0.0-rc.40 463 10/15/2019
7.0.0-rc.39 447 10/12/2019
7.0.0-rc.38 443 10/11/2019
7.0.0-rc.37 439 10/10/2019
7.0.0-rc.36 432 10/9/2019
7.0.0-rc.35 441 10/8/2019
7.0.0-rc.34 442 10/8/2019
7.0.0-rc.33 438 10/7/2019
7.0.0-rc.32 432 10/5/2019
7.0.0-rc.31 440 10/3/2019
7.0.0-rc.30 444 10/1/2019
7.0.0-rc.28 445 10/1/2019
7.0.0-rc.27 441 9/30/2019
7.0.0-rc.26 447 9/30/2019
7.0.0-rc.25 435 9/27/2019
7.0.0-rc.24 432 9/27/2019
7.0.0-rc.23 425 9/26/2019
7.0.0-rc.22 446 9/25/2019
7.0.0-rc.21 446 9/24/2019
7.0.0-rc.20 440 9/23/2019
7.0.0-rc.19 441 9/20/2019
7.0.0-rc.18.1 439 9/20/2019
7.0.0-rc.18 446 9/20/2019
6.5.0-rc.17 468 9/19/2019
6.5.0-rc.16 464 9/18/2019
6.5.0-rc.15 470 9/18/2019
6.5.0-rc.14.1 466 9/18/2019
6.5.0-rc.14 464 9/17/2019
6.5.0-rc.13 453 9/16/2019
6.5.0-rc.12.2 450 9/13/2019
6.5.0-rc.12.1 459 9/12/2019
6.5.0-rc.12 456 9/12/2019
6.5.0-rc.11 461 9/11/2019
6.5.0-rc.10 445 9/10/2019
6.5.0-rc.9 442 9/9/2019
6.5.0-rc.8 451 9/6/2019
6.5.0-rc.7 449 9/6/2019
6.5.0-rc.6 451 9/6/2019
6.5.0-rc.5 446 9/2/2019
6.5.0-rc.4 457 9/2/2019
6.5.0-rc.3 445 8/30/2019
6.5.0-rc.2 471 8/29/2019
6.5.0-rc.1 455 8/28/2019
6.5.0-beta.5 465 8/28/2019
6.5.0-beta.4 458 8/27/2019
6.0.0 798 8/6/2019
6.0.0-rc.7 453 7/19/2019
6.0.0-rc.6 458 6/28/2019
6.0.0-rc.5 451 6/28/2019
6.0.0-rc.4 454 6/25/2019
6.0.0-rc.3 460 6/20/2019
6.0.0-rc.2 463 5/29/2019
6.0.0-rc.1 463 5/28/2019
6.0.0-beta.3 470 4/17/2019
5.3.0-beta.2 474 3/21/2019
5.3.0-beta.1 465 3/20/2019
5.2.0 790 3/19/2019
5.1.0 1,219 1/25/2019
5.0.0 1,277 12/21/2018
5.0.0-rc11 1,036 12/14/2018
5.0.0-rc10 786 11/16/2018
5.0.0-rc09 782 11/1/2018
5.0.0-rc08 751 10/31/2018
5.0.0-rc07 788 10/31/2018
5.0.0-rc06 783 10/30/2018
5.0.0-rc05 784 10/29/2018
5.0.0-rc04 813 10/29/2018
5.0.0-rc03 796 10/26/2018
5.0.0-rc02 792 10/25/2018
5.0.0-rc01 831 10/12/2018
5.0.0-beta03 841 9/21/2018
5.0.0-beta02 844 9/10/2018
5.0.0-beta01 842 9/7/2018
4.5.1 1,258 8/7/2018
4.5.0 1,242 8/7/2018
4.5.0-rc01 1,251 6/7/2018
4.5.0-beta09 1,229 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.