[IronPython] How to do the typeof( ) call on an IronPython implemented class in C#?
janrou at gmail.com
Tue Feb 17 13:54:54 CET 2009
> Can't you do the following?
> ServiceHost selfHost = new ServiceHost(typeof(ICalculator), baseAddress);
The class given as parameter to typeof(..) have to implement the interface.
The interface is the service contract, which the server implements.
I have worked around the problem with a stub, that loads and runs the python
script, see attachment. For each stubbed method it calls the python
It would be smart to get rid of the stub.
public class CalculatorServiceStub : ICalculator
private ICalculator pyCalc;
if (Program.pyr != null)
pyCalc = (ICalculator)Program.pyr.getInstance("PyCalculator");
public double Add(double n1, double n2)
public double Subtract(double n1, double n2)
return pyCalc.Subtract(n1, n2);
public double Multiply(double n1, double n2)
return pyCalc.Multiply(n1, n2);
public double Divide(double n1, double n2)
return pyCalc.Divide(n1, n2);
The class PythonRunner is an adapter for loading, compiling, excuting,
instantiating objects and exchanging variables in and out of the script
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users