C # executes JavaScript code and executes a new way of complex JavaScript code

Source: Internet
Author: User

1.

Using the NuGet package "Jurassic", note that if the packages on NuGet are faulty, download the GitHub code yourself, compile the latest code into a DLL, and then refer to it.

The official NuGet package is probably not up to date.

2.

I am the latest source code download compiled, self-referencing. Because the latest package on NuGet (version number "2.2.2") lacks support for Uint8array.

The latest source code compiled assemblies only support the. net4.5 and. Netstandard 2.0

3.

Examples of compiled usages:

 //Test 3         Public Static BOOLExecutescript (stringRawess,stringCype) {            Object[] para =New Object[] {rawess, cype}; varFuncName ="Validate"; Jurassic.scriptengine engine=NewJurassic.scriptengine (); stringScript =Jsconsts.jscodes; Engine.                         Execute (script); varDD = engine. Getglobalvalue ("Wavalidator"); varValidatefunc = ((objectinstance) dd). Properties.where (q=>q.key=="Validate").            First (); Engine. Setglobalvalue ("Validate", Validatefunc. Value);//This step is to manually add the function to global to facilitate the following code invocation.             varD = engine. callglobalfunction<BOOL>(FuncName, para); returnD; }

4. Execute pass, perfect output JS result! Note that my JS file is the last mini compressed version, using REQUIREJS and other packaged results.

C # executes JavaScript code and executes a new way of complex JavaScript code

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.