This commit is contained in:
@@ -7,60 +7,16 @@ namespace AyaNova.DataList
|
||||
{
|
||||
internal static class DataListFactory
|
||||
{
|
||||
// internal static IAyaDataList GetAyaDataList(string ListKey)
|
||||
// {
|
||||
// switch (ListKey)
|
||||
// {
|
||||
// case nameof(TestWidgetUserEmailDataList):
|
||||
// return new TestWidgetUserEmailDataList();
|
||||
// case nameof(WidgetDataList):
|
||||
// return new WidgetDataList();
|
||||
// default:
|
||||
// throw new System.ArgumentOutOfRangeException($"DataListFactory: Unknown list \"{ListKey}\"");
|
||||
// }
|
||||
// }
|
||||
|
||||
// private static List<string> DataListList = null;
|
||||
|
||||
// //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);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//Instantiate list object specified
|
||||
//this is safe as it's only called from our own code internally
|
||||
//this is safe as it's only attempting to load assemblies in the AyaNova.DataList namespace so can't attempt to instantiate some random object or nefarious object
|
||||
internal static IAyaDataList GetAyaDataList(string ListKey)
|
||||
{
|
||||
System.Reflection.Assembly ass = System.Reflection.Assembly.GetEntryAssembly();
|
||||
return ass.CreateInstance($"AyaNova.DataList.{ListKey}") as IAyaDataList;
|
||||
|
||||
// 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");
|
||||
}
|
||||
|
||||
//List all the datalist types available
|
||||
internal static List<string> GetListOfAllDataListKeyNames()
|
||||
{
|
||||
//https://stackoverflow.com/a/42574373/8939
|
||||
|
||||
Reference in New Issue
Block a user