Hi there,
I do need a solution for loading lists of objects - lookups where only one property is referenced from the current object as in this example.
class LookupObjectAddress
{
[...]
public string City
{ get; set; }
[...]
}
class WorkingObject
{
// references the property from LookupObjectAddress
public string City
{ get; set; }
}
For the lookup I need a List to be loaded from the database, to know from where to load the information I use an Attribute
class WorkingObject
{
// references the property from LookupObjectAddress
[Lookup(Type=typeof(LookupObjectAddress), staticloaderclass="LookupObjLoader", staticloaderMethod="LookupObjLoadMethod")]
public string City
{ get; set; }
}
After reading out the PropertyInfo for the WorkingObject.City Property I know the type of the lookup object, and from which class with which method to load it. Now I need the bridge to get a List with that three parameters to work with.
Type loaderClass = Type.GetType(classname);
MethodInfo loaderMethod = loaderClass.GetMethod(loadmethod);
object objList = loaderMethod.Invoke(null, new object[] {});
Since I need the typed List<> for using properties of the LookupObjects on the UI, how can I become a useable list in Code?
My ideal Outcome would be, if I could just type:
var list = Loader.Load(type, "LookupObjLoader", "LookupObjLoadMethod");
where the parameters are read from the Attribute.