Usually I do this:
MyCustomDocument1 bla1=new MyCustomDocument1()
temp.GeneratesSingleDocument<MyCustomDocument1>(bla1);
MyCustomDocument2 bla2=new MyCustomDocument2()
temp.GeneratesSingleDocument<MyCustomDocument2>(bla2);
MyCustomDocument3 bla3=new MyCustomDocument3()
temp.GeneratesSingleDocument<MyCustomDocument3>(bla3);
But this time I have a list(with all the classes from above):
List<object> allObjects = new List<object>();
It is filled like this(all objects I need):
allObjects.Add(new MyCustomDocument1());
allObjects.Add(new MyCustomDocument2());
allObjects.Add(new MyCustomDocument3());
allObjects.Add(new MyCustomDocument4());
allObjects.Add(new ...());
Now I want to call my generic method with my previous filled list ``:
foreach (var item in allObjects)
{
try
{
//instead of manually calling:
//temp.GeneratesSingleDocument<MyCustomDocument1>(bla1);
//do it generic
temp.GeneratesSingleDocument<typeof(item)>(item);
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
}
}
This does not work:
temp.GeneratesSingleDocument<typeof(item)>(item);
The overall aim is to make some automation, otherwise I have to write a lot of code.
I think this is different from this post.
Thank you.