Hello,

this question is not 100% targeted at IronPython, but I didn't know a better list to write to.

I've started writing a C# <-> javascript bridge. Unlike IronPython and IronRuby I don't want to write a javascript engine in .net, but rather use existing ones. I can already access C# classes from javascript and instance them. The opposite way turns out to be much harder for non-PODs. Example:

public class JSObject
{
// has members like GetProperty/SetProperty which can act upon the javascript object
}

public class TestClass
{
    public string message = "This is a C# string";
}

public class TestApp
{
    public string testComplexObject(TestClass obj)
    {
        return obj.message;
    }

    public void runTest()
    {
        JSObject jsObj = ...;
        string message = testComplexObject(jsObj);
    }
}

The problem here is the "testComplexObject(jsObj)" call. Of course the jsObj cannot be converted directly to a TestClass, because it's an arbitrary javascript object.

I am wondering how IronPython solves this problem. I've read the sources a bit and it seems it makes use of IDynamicMetaObjectProvider etc. If JSObject provided IDynamicMetaObjectProvider, would it allow "converting" the jsObj to a TestClass obj? How?

It's not easy to find information on using the DLR for things like this on the net, so I've asked here. Apologies if I am off-topic.

-Matthias
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to