[IronPython] RuntimeType from PythonType in C# code

Alex News anleewxs at gmail.com
Thu Apr 9 18:14:24 CEST 2009


I have embedded IronPython 2.01 into my C# application, and am
extremely impressed by the ease of integration and the
interoperability with the .NET types.  However I am a bit stumped by
something that probably is quite simple.

1) In a python script, I import one of my application types.
2) From that script I call a function implemented in C#.  I pass in
the type (not an instance of the type)
3) My C# function sees a PythonType.  I would like to get the
associated RuntimeType, but can't figure out how to do so.

For example (using a system type):

python:
from System import String
myfunction(String)  # calls C# delegate defined below

C#:
delegate(object o)
{
  // o is of type PythonType.  I would like to get the associated
System.RuntimeType  (in this case System.String)
}

I've searched the web, but most of the advice seems outdated:

PythonType.UnderlyingSystemType is internal, so I can't access it.
http://lists.ironpython.com/pipermail/users-ironpython.com/2007-December/006130.html

I'm not sure what "Ops" is.  I suspect it is related to the namespace
IronPython.Runtime.Operations, but I can't find an equivalent
class/function in there (although there is quite a bit there, so I may
have missed it).
http://lists.ironpython.com/pipermail/users-ironpython.com/2005-May/000668.html

Any help would be greatly appreciated.

Thanks,
Alex



More information about the Ironpython-users mailing list