IComponentActivator Instance

Posted by jeffn825 on Stack Overflow See other posts from Stack Overflow or by jeffn825
Published on 2010-06-03T02:41:42Z Indexed on 2010/06/03 2:44 UTC
Read the original article Hit count: 475

Filed under:
|

How can I use an IComponentActivator instance for a component, not just specifying a type.

That is, instead of

Component.For<XYZ>.Activator<MyComponentActivator>();

I want to be able say

Component.For<XYZ>.Activator(new MyComponentActivator(someImportantRuntimeInfo));

Also, is there a way I can choose an activator dynamically for a non specifically registered component? That is, I want to have an activator that looks at the type being resolved, decides if it can activate it, and if not, responsibility for activation should be passed on to the default activator.

So basically I want a global IComponentActivator that has the following logic:

Create(Type type){
  if (ShouldActivate(type)){
    DoActivate(type);
  }
  else{
    // do default activation here somehow
  } 
}

Thanks!

© Stack Overflow or respective owner

Related posts about castle-windsor

Related posts about component