Specifying a value dependency with Castle.Windsor

We can use the DependsOn() method to specify a set of constant dependencies. In this case we are telling that the “connectionString” constructor’s parameter of the MyRepository class should be resolved with the value of connStr.

container.Register(
    Component.For<IMyRepository>().ImplementedBy<MyRepository>()
        .DependsOn(new { connectionString = connStr })
);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s