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

New Post: Is there a way to AddHostType with the object named in a string?

$
0
0
I've asked this over on StackOverflow but have included the full question here to save your mouse.

I define JSengine as
    static JScriptEngine JSengine = null;
instantiate it in Main as
    JSengine = new JScriptEngine(WindowsScriptEngineFlags.EnableDebugging | WindowsScriptEngineFlags.EnableJITDebugging);
and then hook various C# objects into it, e.g.
    static void JSSetup(JScriptEngine jse)
    {
        jse.AddHostType("CSString", typeof(String));
        jse.AddHostType("CSConsole", typeof(Console));
        jse.AddHostType("CSFile", typeof(File));
        jse.AddHostType("CSFileInfo", typeof(FileInfo));
        jse.AddHostType("CSDirectory", typeof(Directory));
        jse.AddHostType("CSPath", typeof(Path));
    ....
What I want to know is this: Is there a means whereby I may Add an HostType by specifying it as a string so that I can do something like
    jse.AddHostType("CSPath",fergyTurtle("System.IO.Path"));
The reason for this madness is a desire to be able specify
    CSPath=System.IO.Path
in a configuration file and therefore be able to control what symbols get made available to the called script.

Viewing all articles
Browse latest Browse all 2297

Trending Articles



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