rogergl
rogergl

Reputation: 3781

How to use Custom attributes with MonoTouch and F#

I would like to use some introspection with F# and MonoTouch.

Given the following code fragments:

type Field (aName : string) =
    inherit Attribute()    
    member this.Name = aName

[<Field("title")>]                             
    member this.Title with get() = title

I expected to get the Attribute back with:

reflection.GetCustomAttributes(typeof<Field>, false) 

But that does not work.

But

reflection.GetCustomAttributes(false) 

works but it just returns an array of objects.

Any ideas what I'm doing wrong ?

Regards Roger

Upvotes: 2

Views: 198

Answers (1)

rogergl
rogergl

Reputation: 3781

Problem is solved. Renamed the attribute from Field to FieldInfo and it worked.

Regards Roger

Upvotes: 1

Related Questions