Had an issue at work where I wanted to store my rules and handlers for a class outside of the class definition, so I could better test the component. Found an easy way to add all your rules into StructureMap, and then retrieve those rules as a list via constructor injection.
using System.Collections.Generic;
using System.Linq;
using System.Text;
using StructureMap;
using StructureMap.Configuration.DSL;
public class TravelRegistry : Registry
{
public TravelRegistry()
{
For<ITransportHandler>().Add<ApprovedAccommodationHandler>();
For<ITransportHandler>().Add<ApprovedCharterFlightHandler>();
For<ITransportHandler>().Add<ApprovedCommercialFlightHandler>();
For<ITransportHandler>().Add<ApprovedGroundTransportHandler>();
For<IEnumerable<ITransportHandler>>().Use(x => x.GetAllInstances<ITransportHandler>());
For<ITravelRule>().Add<StartLessThanEndRule>();
For<ITravelRule>().Add<CurrentEndsAfterPreviousRule>();
For<ITravelRule>().Add<CurrentStartAfterPreviousEndRule>();
For<ITravelRule>().Add<UniqueEndsRule>();
For<ITravelRule>().Add<UniqueStartAndEndRule>();
For<ITravelRule>().Add<UniqueStartsRule>();
For<IEnumerable<ITravelRule>>().Use(x => x.GetAllInstances<ITravelRule>());
}
}