I have a base abstract class having a type parameter from another abstract class, as:
public abstract class Database<T> where T : DatabaseItem, new() { //... }
public abstract class DatabaseItem { //... }
Then I have number of children classes inherent from it:
public class ShopDatabase : Database<ShopItem> {}
public class ShopItem : DatabaseItem {}
public class WeaponDatabase : Database<WeaponItem> {}
public class WeaponItem : DatabaseItem {}
//...
Now the problem is, I have an array of Type of Database as:
private static readonly Type[] DATABASE_TYPES = new Type[] {
typeof (ShopDatabase),
typeof (WeaponDatabase)
};
And I want to get all their type parameters as another array, something like this:
Type[] databaseItemTypes = MyFunction (DATABASE_TYPES);
// databaseItemTypes will be an array as: [ShopDatabaseItem, WeaponDatabaseItem]
It may be similar to this question but I don't even have a instance of the Class, so...