TimeGIS
InfoVista.NET
首页             技术文章             专业软件             管理软件             开源软件             知识分享             网站地图            

 程序开发

      图形编辑器

 开发工具


 Web应用开发


 手机移动开发


 建站系统


 企业应用


 服务器


 数据库


 应用工具


 游戏娱乐


 操作系统


 控制仿真



CS-Script

参考:http://www.csscript.net/

CS-Script - The C# Script Engine

C# Script execution engine version 3.5.2

 - Copyright (C) 2004-2013 Oleg Shilo.

Customer Testimonials
 

What a masterful piece of work.  Rarely do we find a piece of "technical art" that is hand-crafted anymore in this field.
Steve N.

Download the latest release  

 Features Download  Documentation/FAQs Tutorials Online Samples Feedback Support
Forum

What is CS-Script?

CS-Script is a CLR (Common Language Runtime) based scripting system which uses ECMA-compliant C# as a programming language. CS-Script currently targets Microsoft implementation of CLR (.NET 2.0/3.0/3.5/4.0/4.5) with full support on Mono. 

CS-Script is an open-source initiative that is distributed under the license agreement, which can be found here. However commercial support is also available.

CS-Script combines the power and richness of C# and FCL with the flexibility of a scripting system. CS-Script can be useful for system and network administrators, developers and testers. For any one who needs an automation for solving variety of programming tasks. 

CS-Script has started as an article at CodeProject but quickly it has grown past the scale of a single publication. Currently it is used world wide for extending the applications functionality with scripting and as a general purpose scripting environment. It is used by both enthusiasts and by professional programmers. It found its way to non-profit organizations (e.g. educational institutes) as well as to commercial organizations. These are just a few examples: MediaPortal, FlashDevelop, K2 APISF.net ("WinTin"), BonSAI, AyaNova (service management software).

The main idea of CS-Script is to allow "plain vanilla" C# code execution from both command-prompt and form any CLR application hosting the script engine.  

Command-prompt execution:

Explorer view:

hello.cs:

using System;
using System.Windows.Forms; 
class Script
    static void Main()
    {
        MessageBox.Show( "Hello World!"); 
    }
}
Script hosting execution:
A. Execution of the script containing class definition:
 
dynamic script = CSScript.Evaluator
                         .LoadCode(@"using System;
                                     public class Script
                                     {
                                         public int Sum(int a, int b)
                                         {
                                             return a+b;
                                         }
                                     }"
);
int result = script.Sum(1, 2);

B. Execution of the script containing method definition only:

dynamic script = CSScript.Evaluator
                         .LoadMethod(@"void SayHello(string greeting)
                                       {
                                           Console.WriteLine(greeting);
                                       }"
);
script.SayHello("Hello World!");

or

var Product = CSScript.Evaluator
                      .CreateDelegate(@"int Product(int a, int b)
                                        {
                                            return a * b;
                                        }
");
int result = (int)Product(1, 2);

or

int result = (int)CSScript.Evaluator.Evaluate("1 + 2");
     CSScript.Evaluator.Run("using System;");
     
CSScript.Evaluator.Run("Console.WriteLine(\"Hello World\\")");

 C. Execution of the script by "aligning" it to the appropriate interface (DuckTyping).
Important aspect of such hosting model that the script execution is completely typesafe and IDEs like VisualStudio can provide full Intellisense support:

1. Script HelloScript.cs
2. Complete script hosting code
using CSScriptLibrary;

public interface IScript
{
    void Hello(string greeting);
}

class Host
{
   
static void Main()
    {
       
IScript script = CSScript.Evaluator
                                 .LoadFile<IScript>("HelloScript.cs");

        script.Hello(
"Hi there...");
    }    
}
CS-Script comes with the complete integration with MS Visual Studio 2010 (CS-Script Visual Studio Tools). Because of the clever loading model CLR Debuggers do not differentiate between static and dynamic code (script). You can debug your script with the same debugger as your host application.

CS-Script can be hosted in NAnt environment. You can execute of both script files and embedded C# code (CDATA) from NAnt build scripts.  The unrestricted bi-directional data exchange between NAnt runtime and CS-Script script code (e.g. C# code) can be achieved due to the advanced CS-Script hosting architecture.

CS-Script also brings you Dynamic Code Generation. The concept, which allows you to define C++ style macros in C#.

CS-Script comes with the full set of comprehensive documentation (tutorials, help in both CHM and PDF format, API reference guide).

Why CS-Script? - read about the difference between CS-Script and other CLR based scripting solutions. This is what you need to know before making a decision on using the CS-Script.

Benefits of C# Scripting System:

  • Simple deployment approach: just bring both script and engine file (about 100 K size) on the system that has .NET runtime installed and script can be run.

  • Portability: Scripts can be run on any system, which has CLR installed (including Mono).

  • Base language is a truly OO language: CS-Script uses full featured C# and also supports VB.NET, C++/CLI and J#. 

  • All .NET functionality is available (FCL, COM Interop, Remoting, WPF, WCF etc.).

  • Easily available Debugger and rich IDE (MS .NET Visual Studio or third-party IDEs).

  • Execution model within the script is the same as for any .NET application: static void Main().

  • Any script can be easily converted into application and vice versa.

  • Optimised interpretation: interpretation of any statement in the script is done only once even if the statement is frequently used throughout the code.

  • Script language is type safe (strongly typed): strong typing is a luxury not available for the most of the scripting languages.

  • All SW development tasks can be done in the same language.

  • GUI development for script application becomes easy.

  • Extensibility: scripting system can be extended by using new assemblies written in any .NET languages or COM components.

  • Script hosting: functionality of any CLR application can be extended with scripting.

    See Features for more details.


共107页  第102页  首页  上一页  下一页  尾页


友情链接 尚禹水利环境 | 我行我速 | SharpDevelop | CSLA.NET | CodePlex | 开源中国社区 | 流体中文网 | 水资讯网 | 上帝之眼 FindSim.NET |
本网页由快手工具软件自动生成,感兴趣者请联系我们。