[IronPython] .NET attributes for methods

Lukas Cenovsky cenovsky at bakalari.cz
Mon Nov 2 18:29:20 CET 2009


I was thinking about this... Does ir mean that (after adding such 
support to clrtype) and building a .dll from the interface class, this 
class can be used from c#?

--
-- Lukáš


Shri Borde wrote:
>
> The clrtype module could be extended to make it possible to declare 
> CLR interfaces in Python code. Something like:
>
>  
>
> class IFoo(object):
>
> *    __metaclass__ = ClrType.ClrInterface # Proposed way to indicate 
> an interface*
>
>     @clrtype.accepts(int, str)
>
>     @clrtype.returns(int)
>
>     @clrtype.attribute(OperationContractAttribute)()
>
>     def foo(i, s):raise RuntimeError("this should not get called")
>
>  
>
> This does not work today...
>
>  
>
> *From:* users-bounces at lists.ironpython.com 
> [mailto:users-bounces at lists.ironpython.com] *On Behalf Of *Lukas Cenovsky
> *Sent:* Friday, October 30, 2009 10:41 AM
> *To:* Discussion of IronPython
> *Subject:* Re: [IronPython] .NET attributes for methods
>
>  
>
> Thanks.
>
> I wanted to implement WCF service in pure Ironpython but I overlooked 
> the [OperationContract] method attribute is used in the interface 
> declaration. Anyway, thanks to class attributes it is now possible to 
> implement the WCF service in IronPython and have only the interface 
> done in C#. See my blog post:
>
> http://gui-at.blogspot.com/2009/10/wcf-service-in-ironpython.html
>
> DllImport is good to have too - I can get rid of of my Win32API.dll 
> when simulating user's input 
> <http://gui-at.blogspot.com/2008/07/simulate-users-input.html> :-)
>
> --
> -- Lukáš
>
>
> Shri Borde wrote:
>
> The following files extend DevHawk's blog and adds support for typed methods with attributes. It will be available as part of the samples released with the 2.6 RTM (over the next month). Do let us know if it works for you. 
>  
> Also, I would be curious to know what scenario you need method attributes for (other than DllImport for pinvokes)...
>  
> -----Original Message-----
> From: users-bounces at lists.ironpython.com <mailto:users-bounces at lists.ironpython.com> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lukas Cenovsky
> Sent: Thursday, October 22, 2009 10:37 AM
> To: Discussion of IronPython
> Subject: [IronPython] .NET attributes for methods
>  
> Hi,
> I have read all DewHawk blogposts about .Net attributes in IronPython 
> via __clrtype__ metaclass 
> (http://devhawk.net/CategoryView,category,__clrtype__.aspx). He 
> describes how to add attributes to classes but not to methods. Is there 
> any example how to add attributes to a method. It looks like method 
> generation is necessary (like for getter and setter or in 
> http://www.voidspace.org.uk/python/weblog/arch_d7_2007_03_10.shtml#e659) 
> but this is kind of deep magic for me...
> Thanks.
>  
> --
> -- Lukáš
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com <mailto:Users at lists.ironpython.com>
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>  
>   
>  
> ------------------------------------------------------------------------
>
>
>   
>  
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com <mailto:Users at lists.ironpython.com>
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   
>
>  
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20091102/1f802534/attachment.html>


More information about the Ironpython-users mailing list