[IronPython] Add/remove python function to C# event in C#

Dino Viehland dinov at exchange.microsoft.com
Mon Jul 14 02:20:09 CEST 2008

Ahh I see what you mean now.  If you're doing this from the hosting APIs you can use the ObjectOperations class to do the conversion:

someObj.someEvent += objOps.ConvertTo<DelegateType>(obj);

A Python specific solution would be doing:

someObj.SomeEvent += (DelegateType)Converter.ConvertToDelegate(obj, typeof(DelegateType));

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dan Eloff
Sent: Sunday, July 13, 2008 5:09 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Add/remove python function to C# event in C#

On Sun, Jul 13, 2008 at 6:50 PM, Dino Viehland
<dinov at exchange.microsoft.com> wrote:
> objOrType.someEvent += somePythonFunctionOrCallableObject
>        And
> objOrType.someEvent -= somePythonFunctionOrCallableObject
> Should just work.

It does just work, in Python. What do I do in C#?

Users mailing list
Users at lists.ironpython.com

More information about the Ironpython-users mailing list