Using Jurassic to run JS functions under. Net

Source: Internet
Author: User

  static void Main (string[] args)        {            var eng = new Jurassic.scriptengine ();            Eng. Evaluate ("function text () {return ten;}");       int rs=     Eng. Callglobalfunction<int> ("text");            Console.WriteLine (RS);            Console.read ();        }

Plugin https://jurassic.codeplex.com/releases/view/115831

How to Receive JS object?

  Class program    {        static void Main (string[] args)        {            var eng = new Jurassic.scriptengine ();            Eng. Evaluate ("function text () {return json.stringify ({' A ': ten, ' B ': ');}");            var rs = eng. Callglobalfunction<string> ("text");            var model = util.serializerjsonorentity.getobject<model> (RS);            Console.WriteLine (MODEL.A);            Console.read ();        }    }    public class Model {public        int a {get; set;}        public int b {get; set;}    }

The scheme mainly through the serialization of receiving can write their own extension function to serialize the JS returned object after serialization in C # as long as the data structure is consistent

Util.SerializerJsonOrEntity.GetObject the function for its own encapsulated serialization function based on the serialization class library of. Net

Using Jurassic to run JS functions under. Net

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.