Which Namespace holds Component.For in Castle Windsor?

419 views Asked by At

I'm learning Castle Windsor and I found this tutorial. In it, there's this code:

private void button1_Click(object sender, EventArgs e)
{
    // CREATE A WINDSOR CONTAINER OBJECT AND REGISTER THE INTERFACES, AND THEIR CONCRETE IMPLEMENTATIONS.
    var container = new WindsorContainer();
    container.Register(Component.For<Main>());
    container.Register(Component.For<IDependency1>().ImplementedBy<Dependency1>());
    container.Register(Component.For<IDependency2>().ImplementedBy<Dependency2>());

    // CREATE THE MAIN OBJECT AND INVOKE ITS METHOD(S) AS DESIRED.
    var mainThing = container.Resolve<Main>();
    mainThing.DoSomething();
}

I'm following along with this, but the Component.For calls are throwing compiler errors for me. Intellisense can't find Component. What namespace should I be using for this call?

I added the Castle.Core and Castle.Windsor references via NuGet. I've been searching through the object browser trying to find Component, but it's a pretty common name. The tutorial inconveniently left out* the usings and I can't find any documentation.

* I find that a lot of tutorials and StackOverflow answers leave out the usings and I can never figure out why.

1

There are 1 answers

0
Patrick Quirk On BEST ANSWER

It's in Castle.MicroKernel.Registration.

That does annoy me too sometimes, though if the project is open source, it's usually easy enough to search their repository.