Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Passing javascript objects to c# native code

$
0
0
I'm trying to create a command-prompt with a functionality like the console.log in my engine.
    public class Konsoll
    {
        public void log(dynamic o)
        {
            Console.WriteLine("Type:" + o.GetType());
            Console.WriteLine(o.ToString());
            // var p = (Microsoft.ClearScript.V8.V8ScriptItem)o;

            // foreach (o.GetType().)
        }

    }
used like this
            using (var engine = new V8ScriptEngine())
            {

                engine.AddHostObject("console", new Konsoll());
                string str;
                while ((str = Console.ReadLine()) != "end")
                {
                    engine.Execute(str);
                }
            }
            Console.ReadLine();
        }
How would you recommend to do this? It would be a very nice start if you made V8ScriptItem public. Maybe this object should rather be of type ExpandoObject?

Viewing all articles
Browse latest Browse all 2297

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>