Is there a class/API in .NET 4.5+ allowing to expose an instance of C# anonymous class as as late-bound object to COM? E.g. I want do this:
webBrowser.Document.InvokeScript("TestMethod", new object[] {
new {
helloProperty = "Hello!",
byeProperty = "Bye!"
}
});
and use it in JavaScript:
function TestMethod(obj)
{
alert(obj.helloProperty + ", " + obj.byeProperty);
}
It should not be a problem to create a helper class to wrap the anonymous object and expose its properties via IReflect, but perhaps, something like this already exists? Just don't want to reinvent the wheel.
I've cooked up a helper class to make it happen, based on this excellent blog post.
Usage:
Code: