On Mon, 2007-03-12 at 17:12 -0500, Ed Fialkowski wrote: > Hi all, I'm pretty much totally new to IronPython and have come to > the > point that I need an interface to interact with a co-worker's code, > but I can't seem to find any documents or discussion on syntax for > writing an interface.
Do you mean calling an interface defined by your co-worker, or implementing an interface in IronPython for you co-worker to call? > Does anyone know of a link that talks about interfaces in IronPython > or feel like explaining one too me? :) To my knowledge you cannot create a class in IronPython to be consumed by C# or VB. I don't know if an IronPython class can implement an interface. To call an explicitly implemented interface, or access the properties of an explicit interface use the following: ISomeInterface.MethodName(instance, args) ISomeInterface.PropertyName.GetValue(instance) ISomeInterface.PropertyName.SetValue(instance, value) As you've probably found attempting to cast, fails. If you need to perform the equivalent of the C# expression 'instance is ISomeInterface' (a QueryInterface?), then you'll find isinstance() fails. Instead, for now use: clr.GetClrType(ISomeInterface).IsAssignableFrom(clr.GetClrType(type(instance))) Here are a couple of relevant bug reports: http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=4538 http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=1506 My thanks to Shri Borde for helping me understand this. Regards, Alex _______________________________________________ users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
