I'm using webforms and I'm wondering how I can remove the followoing concrete reference to a repository. In the past I've used castle windsor with MVC but I don't think I can use that here?
Code behind:
ICustomerRepository repos;
public Workout_Admin()
// here is the offending concrete implementation
: this(new SqlCustomerRepository()) { }
public Workout_Admin(ICustomerRepository repos)
{
this.repos = repos;
}
UPDATED ---
I've updated the static method as suggeted, as well as adding the additional code to the windsor factory
WindsorContainer container;
public WindsorControllerFactory()
{
container = new WindsorContainer(
new XmlInterpreter(new ConfigResource("castle")));
var controllerTypes =
from t in Assembly.GetExecutingAssembly().GetTypes()
where typeof(IController).IsAssignableFrom(t)
select t;
foreach (Type t in controllerTypes)
{
container.AddComponentLifeStyle(t.FullName, t,
LifestyleType.Transient);
}
CommonServiceLocatorPageHandlerFactory.Container = container;
}
The issue that keeps arriseing is with loading the assembly from the config file. The CommonServiceLocatorPageHandlerFactory is in and assembly called yourfit, folder called factory. And here are the relevant configs
<httpHandlers>
<add verb="*" path="*.aspx"
type="YourFit.Factory.CommonServiceLocatorPageHandlerFactory, YourFit"/>
</httpHandlers>
<handlers>
<remove name="UrlRoutingHandler"/>
<add name="CSLPageHandler" verb="*" path="*.aspx"
type="YourFit.Factory.CommonServiceLocatorPageHandlerFactory, YourFit"/>
</handlers>
and the error is:
Could not load type 'YourFit.Factory.CommonServiceLocatorPageHandlerFactory' from assembly 'YourFit'.
I know I'm most likely being really stupid. Thanks so much for your time on this.