1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Hi, I managed to do this trick with a static method, but still not a module binding.

// It goes like this:

#light

type G = G with

  static member f<'t>() : string = 

    typeof<'t>.Name

      

let g (t : System.Type) =

  typeof<G>.GetMethod("f").GetBaseDefinition().MakeGenericMethod([|t|]).Invoke(null, [||])

    

printfn "%A" (g (typeof<int>)) // "Int32"

printfn "%A" (g (typeof<string>)) // "String"

// So the question transforms into this: 

// How to get at a MethodInfo object corresponding to a method defined in a module?

module M = 

  let f = ()

// how to get at MethodInfo of M.f?

// Thanks, --Anton
By on 11/18/2008 8:36 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper