Reputation: 193
I have following C# code
namespace API
{
public class AutoRcu
{
private ...
public AutoRcu()
{
...
}
public void pressKey(string name)
{
...
}
...
}
I am running following IronPython code to operate C# code.
rcu.pressKey("Menu")
Ths works fine but the question is:
I would like to change Python API to run:
API.rcu.pressKey()
instead of
rcu.pressKey()
How to do that?
Now I add such a class by using
pyScope.SetVariable("rcu",AutoRcu)
function.
Upvotes: 0
Views: 165
Reputation: 134841
Well, you're essentially creating an object that has a property rcu
that is an instance of your AutoRcu
class. Just create the object.
dynamic api = new ExpandoObject();
api.rcu = new AutoRcu();
pyScope.SetVariable("API", api);
Upvotes: 1