1 Star 0 Fork 49

码云007/cs-script

forked from 蛋蛋/cs-script 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

CS-Script

Chocolatey Version Chocolatey Downloads NuGet version (CS-Script)

paypal

The project has been migrated to GitHub from CodePlex: CS-Script.

CS-Script is a CLR (Common Language Runtime) based scripting system which uses ECMA-compliant C# as a programming language.

CS-Script is one of the most mature C# scripting solutions. It became publicly available in 2004, two years after the first release of .NET. CS-Script supports both hosted and standalone execution model. It allows seamlessly switching underlying compiling technology without affecting the code base. Currently supported compilers are Mono, Roslyn and CodeDOM. It offers comprehensive integration with most common development tools: Visual Studio, VSCode, Sublime Text 3, Notepad++. It can be run on Win, Linux and Mac. And it is compatible with .NET, Mono and .NET Core (ongoing development).

Over the long history of CS-Script it has been downloaded through Notepad++ plugin manager alone over times.

For the all CS-Script details go to the project Documentation Wiki.


The following is a simple code sample just to give you the idea about the product:

Executing script from shell

Updating media file tags. Note, the script is using optional classless layout.

Script file: mp4_retag.cs

//css_nuget taglib
using System;
using System.IO;

string source = @"\\media-server\tv_shows\Get Smart\Season1";

void main()
{
    foreach (string file in Directory.GetFiles(source, "*.mp4"))
    {
        string episode_name = Path.GetFileNameWithoutExtension(file);

        var mp4 = TagLib.File.Create(file);
        mp4.Tag.Title = episode_name;
        mp4.Save();

        Console.WriteLine(episode_name);
    }
}

Execute script file directly in cmd-promt without building an executable assembly:

C:\Temp>cscs mp4_retag.cs

Hosting script engine

dynamic script = CSScript.LoadCode(
                           @"using System.Windows.Forms;
                             public class Script
                             {
                                 public void SayHello(string greeting)
                                 {
                                     MessageBox.Show($""Greeting: {greeting}"");
                                 }
                             }")
                             .CreateObject("*");
script.SayHello("Hello World!");
//-----------------
var product = CSScript.CreateFunc<int>(@"int Product(int a, int b)
                                         {
                                             return a * b;
                                         }");
int result = product(3, 4);
//-----------------
var SayHello = CSScript.LoadMethod(
                        @"using System.Windows.Forms;
                          public static void SayHello(string greeting)
                          {
                              MessageBoxSayHello(greeting);
                              ConsoleSayHello(greeting);
                          }
                          static void MessageBoxSayHello(string greeting)
                          {
                              MessageBox.Show(greeting);
                          }
                          static void ConsoleSayHello(string greeting)
                          {
                              Console.WriteLine(greeting);
                          }")
                         .GetStaticMethod("SayHello" , typeof(string)); 
SayHello("Hello again!");

空文件

简介

用C#语言去做脚本语言,速度甩Python N条街!而且可以使用.NET全部类库,支持MONO!强烈适合患有“强迫症”的程序猿使用。不像PYthon那样无类型、无定义声明!让你写脚本写的踏实放心!!此代码fork自github! 展开 收起
C#
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/jamesma/cs-script.git
git@gitee.com:jamesma/cs-script.git
jamesma
cs-script
cs-script
master

搜索帮助