저는 프로젝트에서 두 개의 싱글 톤 클래스를가집니다.싱글 톤 팩토리가 복수 싱글 톤 인스턴스를 생성합니다.
public class VStateManager : IVState
{
private static readonly object _createLock = new object();
private static VStateManager _vsManager = null;
public static VStateManager GetVStateManager()
{
lock (_createLock)
{
if (_vsManager == null)
{
return new VStateManager();
}
return _vsManager;
}
}
}
public class VTRFactory : IVTR
{
private static VehicleFactory _VTRFactory =null;
private static readonly object _createLock = new object();
public static VehicleFactory GetVTRFactory()
{
lock(_createLock)
{
if(_VTRFactory == null)
{
return new VTRFactory();
}
return _VTRFactory;
}
}
}
내 동료가 일반적인 인터페이스를 받아 생산하는 싱글 톤 클래스 (something like a singleton factory
)을 만들 제안 모두 singleton objects
방법이 작업을 수행 할 수 있습니다 이.?