>
> Can't you do the following?
>
> ServiceHost selfHost = new ServiceHost(typeof(ICalculator), baseAddress);
>
>
> Michael
>
>>
 No!

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
implemented method:

It would be smart to get rid of the stub.


Regards
Jan Rouvillain

C# stub:

  public class CalculatorServiceStub : ICalculator
  {
    private ICalculator pyCalc;
    public CalculatorServiceStub()
    {
      if (Program.pyr != null)
      {
        Program.pyr.loadscript(@"..\..\..\Calculator\Calculator.py");
        Program.pyr.run();
        pyCalc = (ICalculator)Program.pyr.getInstance("PyCalculator");
      }
    }
    public double Add(double n1, double n2)
    {
      return pyCalc.Add(n1,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
Calculator.py.
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to