C # implement script computing

Source: Internet
Author: User

InterOP. msscriptcontrol must be referenced

Using system;
Using system. Collections. Generic;
Using system. text;
Using msscriptcontrol;

Namespace myquery. csharpscript
{
/// <Summary>
/// Script running error proxy
/// </Summary>
Public Delegate void runerrorhandler ();

/// <Summary>
/// Script running timeout proxy
/// </Summary>
Public Delegate void runtimeouthandler ();

/// <Summary>
/// Script Processing Engine
/// By open-source Shengshi-source code download network is developed based on network articles and is a product of learning custom scripts.
/// </Summary>
Public sealed class scriptengine
{
Private scriptcontrolclass MSC;
/// <Summary>
/// Define a script running error event
/// </Summary>
Public event runerrorhandler runerror;
/// <Summary>
/// Define the script running timeout event
/// </Summary>
Public event runtimeouthandler runtimeout;

/// <Summary>
/// Constructor
/// </Summary>
Public scriptengine ()
: This (scriptlanguage. Javascript)
{
}

/// <Summary>
/// Constructor
/// </Summary>
/// <Param name = "language"> Script Type </param>
Public scriptengine (scriptlanguage LANGUAGE)
{
This. msc = new scriptcontrolclass ();
This. MSC. usesafesubset = true;
This. MSC. Language = language. tostring ();
(Dscriptcontrolsource_event) This. MSC). Error + = new dscriptcontrolsource_erroreventhandler (scriptengine_error );
(Dscriptcontrolsource_event) This. MSC). Timeout + = new dscriptcontrolsource_timeouteventhandler (scriptengine_timeout );
}

/// <Summary>
/// Run the eval Method
/// </Summary>
/// <Param name = "expression"> Expression </param>
/// <Param name = "codebody"> function body </param>
/// <Returns> returned object </returns>
Public object eval (string expression, string codebody)
{
MSC. addcode (codebody );
Return MSC. eval (expression );
}

/// <Summary>
/// Run the eval Method
/// </Summary>
/// <Param name = "language"> script language </param>
/// <Param name = "expression"> Expression </param>
/// <Param name = "codebody"> function body </param>
/// <Returns> returned object </returns>
Public object eval (scriptlanguage language, string expression, string codebody)
{
If (this. Language! = LANGUAGE)
This. Language = language;
Return eval (expression, codebody );
}

/// <Summary>
/// Run the run Method
/// </Summary>
/// <Param name = "mainfunctionname"> name of the entry function </param>
/// <Param name = "Parameters"> parameter </param>
/// <Param name = "codebody"> function body </param>
/// <Returns> returned object </returns>
Public object run (string mainfunctionname, object [] parameters, string codebody)
{
This. MSC. addcode (codebody );
Return MSC. Run (mainfunctionname, ref parameters );
}

/// <Summary>
/// Run the run Method
/// </Summary>
/// <Param name = "language"> script language </param>
/// <Param name = "mainfunctionname"> name of the entry function </param>
/// <Param name = "Parameters"> parameter </param>
/// <Param name = "codebody"> function body </param>
/// <Returns> returned object </returns>
Public object run (scriptlanguage language, string mainfunctionname, object [] parameters, string codebody)
{
If (this. Language! = LANGUAGE)
This. Language = language;
Return run (mainfunctionname, parameters, codebody );
}

/// <Summary>
/// Discard all script code and objects that have been added to scriptcontrol
/// </Summary>
Public void reset ()
{
This. MSC. Reset ();
}

/// <Summary>
/// Obtain or set the script language
/// </Summary>
Public scriptlanguage Language
{
Get {return (scriptlanguage) enum. parse (typeof (scriptlanguage), this. MSC. Language, false );}
Set {This. MSC. Language = value. tostring ();}
}

/// <Summary>
/// Obtain or set the script execution time, in milliseconds
/// </Summary>
Public int timeout
{
Get {return this. MSC. Timeout ;}
Set {This. MSC. Timeout = value ;}
}

/// <Summary>
/// Set whether to display the user interface elements
/// </Summary>
Public bool allowui
{
Get {return this. MSC. allowui ;}
Set {This. MSC. allowui = value ;}
}

/// <Summary>
/// Whether the host application has confidentiality requirements
/// </Summary>
Public bool usesafesubset
{
Get {return this. MSC. usesafesubset ;}
Set {This. MSC. usesafesubset = true ;}
}

/// <Summary>
/// Triggered by the runerror event
/// </Summary>
Private void onerror ()
{
If (runerror! = NULL)
Runerror ();
}

/// <Summary>
/// Ontimeout event triggered
/// </Summary>
Private void ontimeout ()
{
If (runtimeout! = NULL)
Runtimeout ();
}

Private void scriptengine_error ()
{
Onerror ();
}

Private void scriptengine_timeout ()
{
Ontimeout ();
}
}

/// <Summary>
/// Script language Enumeration
/// </Summary>
Public Enum scriptlanguage
{
/// <Summary>
/// JScript Language
/// </Summary>
JScript,

/// <Summary>
/// VBSCRIPT script language
/// </Summary>
VBScript,

/// <Summary>
/// Javascript script language
/// </Summary>
Javascript
}
}

 

Build a basic web development framework (mainly including database processing, page framework and tools) to form a rapid development architecture of ASP. NET information management system.
I. framework implements list query and Chart Display Based on XML Customization
2. The list provides complex query conditions, merged columns (grouping and summation processing), summarized rows, and drill-through data and charts.
3. Editing and configuration supports adding and modifying data in a single table. You can easily expand the new fields in the master table on the editing page implemented by developers.
Enables developers to focus on system business implementation, saving development time and improving development efficiency

Log on to http: // 121.18.78.216/

I only spent one month on the R & D management platform you saw (only eight hours before normal operation.
Therefore, I feel that I have developed an xml configuration implementation interface that enables developers to focus on business implementation and improve the development efficiency of information management systems.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.