1

Suppose I have code like this:

container.RegisterType<IService, Implementation>(name, manager, 
    new InjectionConstructor(...));

Then I need to add InterceptionBehaviour to my registration, so it would be great if class ContainerRegistration have some method like AppendInjectionMembers(...).

So the question is: is it possible to append injectionMembers after registration? And if so, how to do that?

tukaef
  • 9,074
  • 4
  • 29
  • 45

1 Answers1

1

Thanks for all, I found the answer

container.Configure<InjectedMembers>().
    ConfigureInjectionFor<Implementation>(new InterceptionBehavior());

Another way without using obsolete class InjectedMembers:

container.RegisterType(null, typeof(Implementation), new InterceptionBehavior());

Or even using generic version (thanks to Chris Tavares) :

container.RegisterType<Implementation>(new InterceptionBehavior());
tukaef
  • 9,074
  • 4
  • 29
  • 45
  • 1
    You can leave off the initial null, and use generics: container.RegisterType(new InterceptionBehavior()); InjectionMembers are additive; if you configure the same thing (multiple InjectionFactory for example) then last one configured wins. – Chris Tavares Oct 10 '12 at 22:14
  • Can you register multiple behaviors this way? Like: `container.RegisterType(new FirstInterceptionBehavior()); container.RegisterType(new SecondInterceptionBehavior());` – Christian Fredh Oct 31 '14 at 11:33