Advertisement
ptrelford

Funq registerAs

Sep 26th, 2013
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.43 KB | None | 0 0
  1. type IFoo =
  2.    abstract Bar : int -> bool
  3.  
  4. type Foo () =
  5.    interface IFoo with member foo.Bar(x) = true
  6.  
  7. let registerAs<'TAs>(t) =
  8.    let mi = typeof<Funq.Container>.GetMethod("RegisterAs")  
  9.    let mi = mi.MakeGenericMethod([|t;typeof<'TAs>|])
  10.     mi.Invoke(container, [||])
  11.     :?> Funq.IRegistration<'TAs>
  12.  
  13. let container = new Funq.Container()
  14. let x = registerAs<IFoo>(typeof<Foo>)
  15. System.Diagnostics.Debug.WriteLine(x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement