私はこれらの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'はどのようにビルドされていますか? –