Hi egooner,
Yes, that's intentional. Property bags are special in that they expose their keys as if they were members. Exposing their members within the same namespace could create conflict or ambiguity.
If you need to enumerate a property bag, you can use JavaScript's
Another possibility is to expose a property bag's dictionary interface separately from the property bag itself:
and then, in JavaScript:
Cheers!
Why can I not access the PropertyBag's own Keys function is that intentional?
Yes, that's intentional. Property bags are special in that they expose their keys as if they were members. Exposing their members within the same namespace could create conflict or ambiguity.
If you need to enumerate a property bag, you can use JavaScript's
for...in
statement.Another possibility is to expose a property bag's dictionary interface separately from the property bag itself:
var foo = new PropertyBag(); engine.AddHostObject("foo", foo); engine.AddRestrictedHostObject("fooDict", (IDictionary<string, object>)foo);
foo.bar = 123; if (fooDict.Keys.Contains('bar')) { // do something }