Browse Source

Allow delegate types to get a value

CPKreuz 1 year ago
parent
commit
cd63464ceb

+ 8 - 2
src/PixiEditor.AvaloniaUI/ViewModels/Nodes/NodePropertyViewModel.cs

@@ -110,8 +110,14 @@ internal abstract class NodePropertyViewModel : ViewModelBase, INodePropertyHand
 
 
     public static NodePropertyViewModel? CreateFromType(Type type, INodeHandler node)
     public static NodePropertyViewModel? CreateFromType(Type type, INodeHandler node)
     {
     {
-        string name = type.Name;
-        name += "PropertyViewModel";
+        Type propertyType = type;
+        
+        if (type.IsAssignableTo(typeof(Delegate)))
+        {
+            propertyType = type.GetMethod("Invoke").ReturnType;
+        }
+        
+        string name = $"{propertyType.Name}PropertyViewModel";
         
         
         Type viewModelType = Type.GetType($"PixiEditor.AvaloniaUI.ViewModels.Nodes.Properties.{name}");
         Type viewModelType = Type.GetType($"PixiEditor.AvaloniaUI.ViewModels.Nodes.Properties.{name}");
         if (viewModelType == null)
         if (viewModelType == null)