Literal notation & Delegate/Callback

Sep 22, 2010 at 7:39 PM

var contact = {
     "Name": "John Doe",
     "PermissionToCall": true,
     "PhoneNumbers": [
           "Location": "Home",
           "Number": "555-555-1234"
           "Location": "Work",
           "Number": "555-555-9999 Ext. 123"

And on the server...

JintEngine.SetFunction("d"new AddDDelegate(AddD));
public delegate void AddDDelegate(object D);
public void AddD(Object d)


  produces "John Doe"

  products a NULL value

Sep 22, 2010 at 8:01 PM

Well first there is an issue in your code, as John Doe doesn't have any Phone Number in the reality. And I think that 'John Doe' == null is also a correct assertion, as actually John Doe has no identity.

Sep 22, 2010 at 8:15 PM

I don't really know what to return. What would you expect ?

Sep 22, 2010 at 10:00 PM



What I would expect to see happen, is in the "AddD(Object d)" function that the parameter "d" is a reference to the object passed in, from the   d(contact); call, just like the  d(contact.Name); passes the string.



Sep 22, 2010 at 10:06 PM
Edited Sep 22, 2010 at 10:07 PM

Then your delegate should use a JsObject parameter (or maybe JsInstance, I have to check) then there is no conversion to CLR applied, and you get the javascript reference.

Sep 22, 2010 at 10:06 PM

What a beautiful day today, isn't it ?

Sep 22, 2010 at 10:20 PM

Just checked, JSObject works; and then  d["Name"]  will resolve.  Nice.


ps.  Yes..super sunny outside - even up here in Vancouver.  :)

Sep 22, 2010 at 10:26 PM

I know, I'm closer to Vancouver than you are ;)

Sep 23, 2010 at 5:13 PM


Hey wait..  are you in Richmond?



Sep 23, 2010 at 5:47 PM

I work at Microsoft Vancouver and live in Richmond, so closer than Burnaby ;)