다음은다음에 입력 된 팩토리를 사용하고 매개 변수를 생성자에 전달하는 것입니다. 코드에 표시된대로 2 개의 매개 변수 (1, "fo")를 전달하려고하면 형식화 된 팩토리에서이 오류가 발생합니다.Castle Windsor Typed Factory에 매개 변수 전달하기
public class SomeClass {
public ITypedFactory2 F2 { get; set; }
public void SomeFunction() {
var req = F2.Create<IGetFooRequest>(1, "fo"); // ERROR HERE
}
}
public class GetFooRequest : IGetFooRequest {
public int Bar { get; private set; }
public string Ton { get; private set; }
public GetFooRequest(int bar, string ton) {
Bar = bar;
Ton = ton;
}
}
public interface IGetFooRequest{
int Bar { get; }
string Ton { get; }
}
public interface ITypedFactory2 {
T Create<T>(int param1, string param2);
void Release(object t);
}
이는 윈저 설치 부분입니다 ...
container.AddFacility<TypedFactoryFacility>();
container.Register(Component.For<ITypedFactory2>().AsFactory());
container.Register(AllTypes
.FromAssemblyContaining<IGetFooRequest>()
.Where(type => type.Name.EndsWith("Request"))
.WithService.AllInterfaces().LifestyleTransient());
가 왜 비 선택적인 종속성을 확인할 수 없습니다 말한다 ...? 나는 안으로 통과했다 (1, "fo"); 왜 이런 일이 일어 났는지 이해가 안돼. 제발 도와주세요.
답변으로 표시되지 않는 이유는 무엇입니까? – neverseenjack
답변으로 표시됨 –