Is it possible to declare IronPython classes as “Export” and thus add them to a MEF catalog that a
host C# application can Import?
I cannot really find any concrete examples of this, just speculation.
Here is how I have manually loaded a Python class that implements a .NET interface:
https://github.com/versionone/VersionOne.SDK.Experimental
I would like to be able to put attributes on the python classes similar to how you do it in C#.
(Or something equivalent)
Has anyone tried this?
Thanks,
Josh
For those interested, I found a project on GitHub that had done this, but was a little bit coupled into the project. With the author’s approval I’ve created a new repo, IronPythonMef, and a NuGet package for it.
There’s additional discussion in this thread at GitHub.
Here’s an example of how it works:
First, an interface declared in C#:
An implementation that Exports that interface in C#:
And, an implementation of IOperation in IronPython:
And here’s a test case of a class that imports these operations from both C# and IronPython and executes them: