나는이 2 개 개의 클래스가 있다고 가정 :다른 클래스가 사용하기 전에 정적 컬렉션이 초기화/채워지도록 보장되어 있습니까?
public class A<T> where T : IEntityWithID, new()
{
private static EntityInfo entityInfo = B.GetEntityInfo(typeof(T));
private static IEnumerable TestCases
{
// Do work with entityInfo...
}
}
private static class B
{
private static IList<EntityInfo> entityInfoList = B.GetEntityList();
public static EntityInfo GetEntityInfo(Type type)
{
return entityInfoList.Single(e => e.Types.Contains(type));
}
private static IList<EntityInfo> GetEntityList()
{
// Builds a list of EntityInfo's...
}
}
는 클래스 B의 entityInfoList인가를 초기화 B.GetEntityInfo 전에 채워 보장() 클래스 A에서라고?
'B.GetEntityInfo()'는 어디에 있습니까? 너는 그것을 보여주지 않는다. – itsme86
B.GetEntityInfo() 정의 추가 ... – Andrew
'GetEntityList '는 어떻게 구축 되었습니까? –