return static class

May 6, 2013 at 7: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 9:05 PM
Edited Aug 3, 2013 at 2: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 12: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!