This commit is contained in:
@@ -20,33 +20,45 @@ namespace AyaNova.DataList
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// internal static List<string> DataListList = null;
|
// private static List<string> DataListList = null;
|
||||||
|
|
||||||
// private static void PopulateDataListList(){
|
// //To be called at startup
|
||||||
// DataListList= new List<string>();
|
// private static void PopulateDataListCache()
|
||||||
// foreach (System.Reflection.TypeInfo ti in ass.DefinedTypes)
|
// {
|
||||||
// {
|
// System.Reflection.Assembly ass = System.Reflection.Assembly.GetEntryAssembly();
|
||||||
// if (ti.ImplementedInterfaces.Contains(typeof(IAyaDataList)))
|
// DataListList = new List<string>();
|
||||||
// {
|
// foreach (System.Reflection.TypeInfo ti in ass.DefinedTypes)
|
||||||
// DataListList.Add(ti.Name);
|
// {
|
||||||
// }
|
// if (!ti.IsAbstract && ti.ImplementedInterfaces.Contains(typeof(IAyaDataList)))
|
||||||
// }
|
// {
|
||||||
|
// DataListList.Add(ti.Name);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
//This may be fast enough to not cache but let's see
|
//Instantiate list object specified
|
||||||
|
//this is safe as it's only called from our own code internally
|
||||||
internal static IAyaDataList GetAyaDataList(string ListKey)
|
internal static IAyaDataList GetAyaDataList(string ListKey)
|
||||||
{
|
{
|
||||||
System.Reflection.Assembly ass = System.Reflection.Assembly.GetEntryAssembly();
|
System.Reflection.Assembly ass = System.Reflection.Assembly.GetEntryAssembly();
|
||||||
|
return ass.CreateInstance($"AyaNova.DataList.{ListKey}") as IAyaDataList;
|
||||||
|
|
||||||
foreach (System.Reflection.TypeInfo ti in ass.DefinedTypes)
|
// if (DataListList == null)
|
||||||
{
|
// {
|
||||||
// if (!ti.IsAbstract && ti.ImplementedInterfaces.Contains(typeof(IAyaDataList)))
|
// throw new System.NullReferenceException($"DataListFactory::GetAyaDataList({ListKey}) -> The data list cache is empty!");
|
||||||
if(ti.Name==ListKey)
|
// }
|
||||||
{
|
|
||||||
return ass.CreateInstance(ti.FullName) as IAyaDataList;
|
// System.Reflection.Assembly ass = System.Reflection.Assembly.GetEntryAssembly();
|
||||||
}
|
|
||||||
}
|
// foreach (System.Reflection.TypeInfo ti in ass.DefinedTypes)
|
||||||
throw new System.ArgumentOutOfRangeException($"DEV ERROR in DataListFactory.cs: ListKey {ListKey} specified doesn't exist");
|
// {
|
||||||
|
// // if (!ti.IsAbstract && ti.ImplementedInterfaces.Contains(typeof(IAyaDataList)))
|
||||||
|
// if (ti.Name == ListKey)
|
||||||
|
// {
|
||||||
|
// return ass.CreateInstance(ti.FullName) as IAyaDataList;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// throw new System.ArgumentOutOfRangeException($"DEV ERROR in DataListFactory.cs: ListKey {ListKey} specified doesn't exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static List<string> GetListOfAllDataListKeyNames()
|
internal static List<string> GetListOfAllDataListKeyNames()
|
||||||
@@ -58,7 +70,7 @@ namespace AyaNova.DataList
|
|||||||
|
|
||||||
foreach (System.Reflection.TypeInfo ti in ass.DefinedTypes)
|
foreach (System.Reflection.TypeInfo ti in ass.DefinedTypes)
|
||||||
{
|
{
|
||||||
if (ti.ImplementedInterfaces.Contains(typeof(IAyaDataList)))
|
if (!ti.IsAbstract && ti.ImplementedInterfaces.Contains(typeof(IAyaDataList)))
|
||||||
{
|
{
|
||||||
ret.Add(ti.Name);
|
ret.Add(ti.Name);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user