제목이 적어도 일부 의미를 갖기를 바랍니다.윈저에 등록 오픈 제네릭 타입의 일반 서비스 용 오픈 제네릭 타입 구성 요소
아래 코드와 같은 상황이 있습니다. 테스트를 통과,하지만 난 GenericCommandHandler에게 주어진 유형의 수가 제한되어 있기 때문에,
IHandler<GenericCommand<>>
나는 아래의 것을 살 수
에 대한 구현 등
GenericCommandHandler<>
오픈 제네릭 형식을 등록하려고하고 개별적으로 등록 할 수는 있지만 더 많은 것을 "자동화"하고 싶습니다.
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using NUnit.Framework;
[TestFixture]
public class Class1
{
[Test]
public void t()
{
using(var container = new WindsorContainer())
{
// HOW TO REGISTER IT AS OPEN GENERIC TYPE?
container.Register(
Component.For<IHandler<GenericCommand<object>>>()
.ImplementedBy<GenericCommandHandler<object>>());
var handler = container.Resolve<IHandler<GenericCommand<object>>>();
}
}
}
public interface IHandler<TCommand>
{
void Handle(TCommand o);
}
public class GenericCommand<T>
{
}
public class GenericCommandHandler<T> : IHandler<GenericCommand<T>>
{
public void Handle(GenericCommand<T> o)
{
}
}
이제 기사와 지미 밀러를 모두 읽었습니다. 고마워,이 작동합니다. – Artur