Как установить общий параметр только для определенных параметров типа в этом установщике Windsor, используя свободный API? - PullRequest
0 голосов
/ 17 ноября 2010

У меня в настоящее время есть этот установщик:

class DemiInstaller : IWindsorInstaller
{
    public void Install(IWindsorContainer container, 
        IConfigurationStore store)
    {
        List<Type> types = new List<Type>
        {
            typeof(ServicePlan),
            typeof(AccountGetService),
            typeof(ServiceOrder),
            typeof(WorkRosterHistory),
            typeof(WorkRoster),
            typeof(SmallHoursAmount),
            typeof(Nurse),
            typeof(ServicePlanHistory),
            typeof(ServicePlanLine),
            typeof(ServicePlanLineHistory),
            typeof(AccountGetServiceAbsence),
            typeof(NurseAbsence),
            typeof(Holiday)
        };

        foreach (var type in types)
        {
            container.Register(
                Component
                .For(typeof(IRepository<>)
                    .MakeGenericType(type))
                .ImplementedBy(typeof(ARRepository<>)
                    .MakeGenericType(type)));
        }
    }
}

Вместо перебора списка есть функция в Fluent API Windsor, которая реализует этот тип поведения?
Могу ли я выполнять другие виды фильтрациина основе универсального типа?

Ответы [ 2 ]

2 голосов
/ 17 ноября 2010

Просто зарегистрируйтесь

container.Register(Component.For(typeof(IRepository<>)).ImplementedBy(typeof(ARRepository<>)));
1 голос
/ 17 ноября 2010
container.Register(AllTypes.FromThisAssembly()
                            .BasedOn(typeof(IRepository<>))
                            .WithService.FromInterface());
...