You'll want to look at the DLR overview doc and then the Sympl sample walkthrough doc: http://dlr.codeplex.com/wikipage?title=Docs%20and%20specs&referringTitle=Home&ProjectName=dlr
You'll want to type the parameter to testComplexObject as 'dynamic' and implement IDMOP on JSObject, which you can see how to do from the Sympl sample. Now, the Sympl sample is VERY light on real .NET bindin, but if it all maps to GetProp/SetProp, then maybe this is fine. If you might flow into your code a regular C# object (not just a JSObj), then you may want to make use of the DefaultBinder from the DLR project, which is what the Iron languages use to get much richer binding. You could also make use of the C# runtime binder to get C#'s semantics for binding members of objects at runtime, but you get that for free if you declare the parameter 'dynamic' and have your JSOjbectMetaObject simply punt whenever the object is not a derived type of JSObject. You get that for free because you'll call back on the binder at the obj.message call site, and C# will have compiled that callsite to use its binder. Bill -----Original Message----- From: users-boun...@lists.ironpython.com [mailto:users-boun...@lists.ironpython.com] On Behalf Of Matthias Sent: Tuesday, March 29, 2011 3:34 AM To: users@lists.ironpython.com Subject: [IronPython] IronLanguages 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 _______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com