Able to specify alternative to "undefined"?

Sep 1, 2011 at 9:22 PM

I have a particular object type that I'd like to have any "undefined" members not be undefined.  I'd like them to actually be some other CLR class and on first reference, new a CLR object and add it to the objects member list.

For example:

myobj.something_undefined.Go();

At the point of looking at "something_undefined", I'd like for it to create a new instance of a CLR class and assign it to myobj, then call Go().

Is this possible?

...Matt

Developer
Sep 3, 2011 at 12:40 AM

Yes, it's possible, you need to create you own class, derive if from 'JsObject' and override 'TryGetDescriptor' method, to make him creating missing properties at access attempts.