This commit is contained in:
2020-01-21 21:27:09 +00:00
parent bfef5d4787
commit 516f1d41cb
3 changed files with 41 additions and 11 deletions

View File

@@ -13,7 +13,7 @@ namespace AyaNova.DataList
internal abstract class AyaDataList : IAyaDataList
{
internal AyaDataList()
public AyaDataList()
{
}

View File

@@ -7,20 +7,51 @@ 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}\"");
// }
// }
// internal 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);
// }
// }
// }
//This may be fast enough to not cache but let's see
internal static IAyaDataList GetAyaDataList(string ListKey)
{
switch (ListKey)
{
case nameof(TestWidgetUserEmailDataList):
return new TestWidgetUserEmailDataList();
default:
throw new System.ArgumentOutOfRangeException($"DataListFactory: Unknown list \"{ListKey}\"");
}
}
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()
{
//https://stackoverflow.com/a/42574373/8939
List<string> ret = new List<string>();
System.Reflection.Assembly ass = System.Reflection.Assembly.GetEntryAssembly();
@@ -33,7 +64,6 @@ namespace AyaNova.DataList
}
}
return ret;
}

View File

@@ -14,7 +14,7 @@ namespace AyaNova.DataList
//NOTE: Due to the join, all the sql id and name fields that can conflict with the joined (in this case User) table need to be specified completely
FieldDefinitions = new List<AyaDataListFieldDefinition>();
FieldDefinitions.Add(new AyaDataListFieldDefinition { LtKey = "df", AyaObjectType = (int)AyaType.Widget, SqlIdColumnName = "awidget.id" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { FieldKey = "df", AyaObjectType = (int)AyaType.Widget, SqlIdColumnName = "awidget.id" });
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
LtKey = "WidgetName",