mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Fixed CreateClass to create a generic MyClass<object> when MyClass<T> is passed (#1153)
This commit is contained in:
@@ -344,6 +344,20 @@ namespace UICatalog {
|
||||
|
||||
View CreateClass (Type type)
|
||||
{
|
||||
// If we are to create a generic Type
|
||||
if (type.IsGenericType) {
|
||||
|
||||
// For each of the <T> arguments
|
||||
List<Type> typeArguments = new List<Type> ();
|
||||
|
||||
// use <object>
|
||||
foreach (var arg in type.GetGenericArguments ()) {
|
||||
typeArguments.Add (typeof (object));
|
||||
}
|
||||
|
||||
// And change what type we are instantiating from MyClass<T> to MyClass<object>
|
||||
type = type.MakeGenericType (typeArguments.ToArray ());
|
||||
}
|
||||
// Instantiate view
|
||||
var view = (View)Activator.CreateInstance (type);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user