Last active
August 29, 2015 14:23
-
-
Save omares/43d026488a846f105e13 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SomeClass is stored as typeof in a var | |
Func<SomeClass> factory = () => Container.GetInstance<SomeClass>(); | |
Container.Register<Lazy<SomeClass>>(() => new Lazy<SomeClass>(factory)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var lazy = typeof(Lazy<>).MakeGenericType(type); | |
var method = typeof(SimpleInjectorExtensions).GetTypeInfo().GetDeclaredMethod("RegisterLazy").MakeGenericMethod(lazy); | |
method.Invoke(container, new object[] {container }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment