2
XML 설정 파일에서 사용자 정의 평생 생성자에 매개 변수를 전달 : 이제유니티 :이처럼 내 CustomLifetimeManager 썼다
public class CustomLifetimeManager <T> : LifetimeManager
{
private readonly string _arg;
public CustomLifetimeManager(string arg)
{
_arg = arg;
}
}
은 쉽게 프로그래밍 용기를 구성 작동하지만 다음과 같이 구성 파일에 어떻게 추가 ?
<type type="myTime"
mapTo="myImpl">
<lifetime type="CustomLifetimeManager"/>
</type>
설정을 읽으시겠습니까? 그렇다면 값이있는 키를 추가하고 다음과 같이 읽습니다. string configValue = System.Configuration.ConfigurationManager.type [ "keyName"]; – MrFox
아니요, 전화를 걸어주세요 : unityConfigurationSection.Containers [0] .Configure (Container) 내 컨테이너를 구성합니다. 구성 파일에 수명 관리자를 구성하고 싶습니다. – onof