Release v3.9.3.0

Rating: No reviews yet
Downloads: 275
Change Set: 6cfb743fbb9f
Released: Feb 16, 2015
Updated: Feb 19, 2015 by oleg_s
Dev status: Stable Help Icon

Recommended Download

Application cs-script.7z
application, 4796K, uploaded Feb 19, 2015 - 172 downloads

Other Available Downloads

Application cs-script.ExtensionPack.7z
application, 896K, uploaded Feb 16, 2015 - 54 downloads
Application cs-scriptDocs.7z
application, 3352K, uploaded Feb 16, 2015 - 49 downloads

Release Notes

cs-script.7z - CS-Script Suite (binaries, documentation, samples)
cs-script.ExtensionPack.7z - CS-Script Extension Pack (additional binaries and samples)
cs-scriptDocs.7z - CS-Script Documentation

CS-Script published on Chocolatey repository

Chocolatey is the repository for the Windows software packages. "Chocolatey NuGet is a Machine Package Manager, somewhat like apt-get, but built with Windows in mind." It is also the source repository of the OneGet package manager of Windows 10.
CS-Script can be installed with the following command:
C:\> choco install cs-script
Read more on Chocolatey and how to enable it on your version of windows here: https://chocolatey.org/

NOTE: The package may not be available immediately as it may take some time for the package to get approved on Chocolatey.

Implemented support for custom source/assembly probing

Added CSScript.ResolveAssemblyAlgorithm and CSScript.ResolveSourceAlgorithm
In some cases you may find that you need to have a complete control over assembly and script probing mechanism. In such cases the host application can supply the custom probing algorithm (ResolveAssemblyAlgorithm/ResolveSourceAlgorithm). The code sample below shows how to implement custom probing for the assembly referenced by alias 'forms' (e.g. '//css_ref forms')

var findFile = CSScript.ResolveSourceAlgorithm;
CSScript.ResolveSourceAlgorithm = (file, searchDirs, throwOnError) =>
{
    if (file == "env") //create source file dynamically
    {
        var env = Path.GetFullPath("env");
        File.WriteAllText(env, "class Env{public static string Name = \"CS-Script\";}");
        return env;
    }
    return findFile(file, searchDirs, throwOnError);
};
//------------------------
var findAsm = CSScript.ResolveAssemblyAlgorithm;
CSScript.ResolveAssemblyAlgorithm = (name, searchDirs) =>
{
    if (name == "forms")
        return new[] { typeof(System.Windows.Forms.Form).Assembly.Location };
    else
        return findAsm(name, searchDirs);
};
//------------------------
var code = @"//css_inc env
             //css_ref forms
             void SayHello(string greeting)
             {
                 System.Windows.Forms.MessageBox.Show(greeting + "" from "" + Env.Name);
             }";

var sayHello = CSScript.LoadMethod(code).GetStaticMethod();

sayHello("Hello");

This technique allows achieving a very flexible probing. You can generate the source file on fly, download the assembly from the Internet, check the integrity (or even decrypt) of the user supplied C# file or even implement license-based access to the specific assemblies.
See <cs-script>\Samples\Hosting\CustomProbing.cs sample for details.

Reviews for this release

No reviews yet for this release.