This project has moved and is read-only. For the latest updates, please go here.

return static class

May 6, 2013 at 8:44 PM
after binding a static class 'mouse' with AddHostType, i can access the static members as follows:;

now, i want to enable the following functionality:;
while click returns the static mouse class, hence we call the click() function two times.

i know this is not possible in c#, but it is a common syntax in javascript. is there any way i can return the static class to be reused by the engine?
May 6, 2013 at 10:05 PM
Edited Aug 3, 2013 at 3:25 AM
Hi mleandrok,

One way to do this is to use ClearScript's ExtendedHostFunctions class. It's not exactly the intended usage, but it works:
public static class Mouse
    private static readonly object thisHostType =
                new ExtendedHostFunctions().type(typeof(Mouse));

    public static object click(string arg)
        // do whatever this method normally does

        // return host type for call chaining
        return thisHostType;
and then
engine.AddHostType("mouse", typeof(Mouse));
May 7, 2013 at 1:39 AM
works like a charm. thanks for the fast answer and all the effort you put into this project. really brings scripting in c# to a whole new level. perfect synergy with the host language. cheers!