Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var namedInjector = ObjectFactory.GetNamedInstance<IInjectable>("Other");
- .ForRequestedType<MementoType>()
- .AddConcreteType<ConcreteType>(instanceName)
- class MyRegistry : Registry {
- public MyRegistry() {
- this.ForRequestedType<IFoo>()
- .TheDefaultIsConcreteType<Bar>()
- .AddInstances( x => {
- x.OfConcreteType<Blap>().WithName("abc");
- });
- }
- }
- ...
- ObjectFactory.Configure(x=>x.AddRegistry<MyRegistry>());
- IFoo test1 = ObjectFactory.GetInstance<IFoo>(); // Bar
- IFoo test2 = ObjectFactory.GetNamedInstance<IFoo>("abc"); // Blap
- ...
- interface IFoo {}
- public class Bar : IFoo {}
- public class Blap : IFoo {}
Add Comment
Please, Sign In to add comment