Greetings jnair, and thanks for your question!
Unfortunately ClearScript doesn't have a complete solution for private member access. As you've discovered,
Here's one thing you can do. Let's say your classes look like this:
You can expose the base portion of your object separately, with its own
It's a bit ugly, but it works :)
Cheers!
Unfortunately ClearScript doesn't have a complete solution for private member access. As you've discovered,
PrivateAccess
only goes so far, and casting doesn't propagate it.Here's one thing you can do. Let's say your classes look like this:
publicclass FooBase { privateint PrivateBaseField; } publicclass Foo : FooBase { privatestring PrivateField; }
PrivateAccess
flag:var foo = new Foo(); engine.AddHostObject("foo", HostItemFlags.PrivateAccess, foo); engine.AddRestrictedHostObject("fooBase", HostItemFlags.PrivateAccess, (FooBase)foo); engine.Execute(@" foo.PrivateField = 'bar'; fooBase.PrivateBaseField = 123; ");
Cheers!