aaron.wells (2) [Avatar] Offline
#1
I'm looking for hints and a concrete implementation for injecting the steps of a named pipeline when using Castle Windsor, or other DI Container. Ideally, I'd like to use the Typed Factory Facility in Castle Windsor. I already have a custom factory that does this work, but it seems as if most of the work should be performed by the DI Container itself.

In my solution, are lots of implementations of IStep<> (Load<>, Verify<>, Update<>, Delete<>, etc..). I need to be able to provide either a named IPipeline<> or IStep<>[] that resolves a subset of all the registered IStep<> for the needed pipelines. Ideally the following signatures would apply:

public interface IStep<T>{}

public interface IPipeline<T>{
  IStep<T> Steps();
} 

public interface IFactory{
  IPipeline<T> GetFirstPipeline();
  IPipeline<T> GetSecondPipeline();
... or ...
  IStep<T>[] GetFirstPipelineSteps();
  IStep<T>[] GetSecondPipelineSteps();
}

container.Register(
  Classes.FromThisAssembly().BasedOn(typeof(IStep<>).WithServiceBase(),
  Classes.FromThisAssembly().BasedOn(typeof(IPipeline<>).WithServiceBase(),
  Component.For<IPipelineFactory>().AsFactory()
);


In any case, what I need is for the factory to resolve a configurablly named subset of all the IStep<T> that could be resolved.

Any help is much appreciated!

aaron.wells (2) [Avatar] Offline
#2
I found what I was looking for. In the book, Mark talks about "wiring sequences", but the "Service Overrides" portion of the API that he used was deprecated. The replacement mechanism is called "Depends On". His example:
                .ServiceOverrides(new
                    {
                        courses = new[] 
                            {
                                "entrée",
                                "mainCourse",
                                "dessert" 
                            }
                    })

becomes:
                .DependsOn(
                    Dependency.OnComponentCollection(
                    "courses", new[]
                    {
                        "entrée", 
                        "mainCourse", 
                        "dessert"
                    })
                ));