cs简单python代码_cs-script: 用C#语言去做脚本语言,速度甩Python N条街!而且可以使用.NET全部类库,支持MONO!强烈适合患有“强迫症”的程序猿使用。不像PYthon那样...

CS-Script是一个基于CLR的C#脚本系统,自2004年起提供,支持托管和独立执行模型,可用作PowerShell的纯C#替代品,并能与多种开发工具无缝集成。它可以在Win、Linux和Mac上运行,兼容.NET、Mono和.NET Core。脚本示例展示了如何更新媒体文件标签和执行方法。
摘要由CSDN通过智能技术生成

CS-Script

CS-Script is a CLR 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, just two years after the first release of .NET. And it was the first comprehensive scripting platform for .NET

CS-Script supports both hosted and standalone execution model. This makes it possible to use the script engine as a pure C# alternative for PowerShell. As well as extending .NET applications with C# scripts executed at runtime by the hosted script engine.

CS-Script allows seamlessly switching underlying compiling technology without affecting the code base. Currently supported compilers are Mono, Roslyn and CodeDOM.

CS-Script also offers comprehensive integration with most common development tools:

It can be run on Win, Linux and Mac. And it is compatible with .NET, Mono and .NET Core.

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

times (see stats).

* statistics does not include x64 downloads nor downloads after Notepad++ discontinued shiping editor with the plugin manager x86 included

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-prompt 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 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" , "");

SayHello("Hello again!");

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值