I've inherited a bloated project that has been maintained by about six developers before I arrived here. This project takes 15 excel files as input, stores the values of those files in a huuuuuge class that serves as in-memory DB, runs a ton of calculations and returns about ten new files with the results of those calculations.
To try and make this testable, I tried adding a generic extension method to allow me to instantiate a class (this is no issue) and add those to an existing List.
I know how I can find the type of List I need using reflection, but what I don't know is how to return the already instantiated List of the in-memory database. Does anyone know if this is possible? I've added a quick example of this in-memory db below:
public class Database
{
public class Parameter
{
public string Code { get; set; }
public string Label { get; set; }
public List<ParameterValue> paramValues;
}
public class ParameterValue
{
public string Value { get; set;}
public Parameter parameter { get; set;}
}
public List<Parameter> parameters;
}
Obviously this class is hugely simplified (the Database defines several different Parameter classes and has most of those classes as List properties), but my question really is this:
Is it possible to get an already instantiated List<T>
from a Database instance using reflection, if given T?
My apologies in advance if this has already been answered - I searched but didn't find an answer.
Robrecht
Aucun commentaire:
Enregistrer un commentaire