Refer to the code below.
dbConn.Open();
List<MigrateAnnex> list13 = dbConn.ReadAll<MigrateAnnex>(parameter.SQLQuery);
dbConn.Close();
//convert to csv
using (var writer = new StreamWriter(parameter.FullPath))
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
{
csv.Context.RegisterClassMap<MigrateAnnexMap>();
csv.WriteRecords(list13);
}
break;
I have this snippet of code and what I want to achieve is I need to make a method that will call this line of code and make the type as the parameter. I'm aware of generics and reflection but I don't want to have a line of code that will call the generic method and pass the parameter but instead, I just want to load all the possible classes that I have in my project then using reflection I can inject the type to call the generic method.
I have these classes within the main project and these classes are the parameters that I need to pass on the generic method. The question is how can I do that, I already used Assembly.LoadFrom where I can load directly the dll but I don't want to make another class library. I just want to stay my classes on the same project for simplicity sake. I don't know if there are other option to use Assembly.LoadFrom or a much better approach to solve my issue.
Aucun commentaire:
Enregistrer un commentaire