This commit is contained in:
2020-01-21 21:35:09 +00:00
parent 516f1d41cb
commit 5c0a66011a

View File

@@ -20,33 +20,45 @@ namespace AyaNova.DataList
// }
// }
// internal static List<string> DataListList = null;
// private static List<string> DataListList = null;
// private static void PopulateDataListList(){
// DataListList= new List<string>();
// foreach (System.Reflection.TypeInfo ti in ass.DefinedTypes)
// {
// if (ti.ImplementedInterfaces.Contains(typeof(IAyaDataList)))
// {
// DataListList.Add(ti.Name);
// }
// }
// //To be called at startup
// private static void PopulateDataListCache()
// {
// System.Reflection.Assembly ass = System.Reflection.Assembly.GetEntryAssembly();
// DataListList = new List<string>();
// foreach (System.Reflection.TypeInfo ti in ass.DefinedTypes)
// {
// 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)
{
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 (!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");
// if (DataListList == null)
// {
// throw new System.NullReferenceException($"DataListFactory::GetAyaDataList({ListKey}) -> The data list cache is empty!");
// }
// System.Reflection.Assembly ass = System.Reflection.Assembly.GetEntryAssembly();
// foreach (System.Reflection.TypeInfo ti in ass.DefinedTypes)
// {
// // 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()
@@ -58,7 +70,7 @@ namespace AyaNova.DataList
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);
}