0

I started using Iron Python by following this example : How can I call (Iron)Python code from a C# app?

What I was wondering is the following : how can I tell IronPython which methods should be available to be called from a script whenever I get an object that is from a given namespace because I don't want to expose the full functionality of the namespace?

tl;dr : Say I have object A exposed to be created in my python script. How can I limit what A can do without explicitly having to move it to a new type?

Community
  • 1
  • 1
Christo S. Christov
  • 2,268
  • 3
  • 32
  • 57

1 Answers1

1

Use typed objects and expose them to the script engine using SetVariable.

Also think out the flow you want to expose to the user before defining the APIs on such an object.

this.proxy = new MySpecialType();
engine.GetBuiltinModule().SetVariable("proxy", this.proxy);
cbuteau
  • 736
  • 1
  • 7
  • 15