浏览代码

Fixed enclosed entity editors

Kenric Nugteren 4 月之前
父节点
当前提交
f4cd677895

+ 0 - 2
InABox.Client.RPC/Transports/RPCClientTransport.cs

@@ -116,8 +116,6 @@ namespace InABox.Rpc
                 if (!Connect(CancellationToken.None))
                     throw new RpcException($"Transport Disconnected: {typeof(TCommand).Name}()", RpcError.DISCONNECTED);
             }
-
-            
         }
 
 

+ 14 - 6
inabox.wpf/DynamicGrid/Editors/DynamicEditorControlFactory.cs

@@ -20,13 +20,21 @@ namespace InABox.DynamicGrid
                 foreach(var type in CoreUtils.TypeList(AppDomain.CurrentDomain.GetAssemblies(),
                     x => x.IsClass
                         && !x.IsAbstract
-                        && !x.IsGenericType
-                        && x.IsSubclassOfRawGeneric(typeof(DynamicEditorControl<,>))))
+                        && !x.IsGenericType))
                 {
-                    var editorClass = type.GetSuperclassDefinition(typeof(DynamicEditorControl<,>))!;
-                    var valueType = editorClass.GenericTypeArguments[0];
-                    var editor = editorClass.GenericTypeArguments[1];
-                    if (editor == typeof(IBaseEditor) || editor.HasInterface<IBaseEditor>())
+                    Type? valueType = null;
+                    Type? editor = null;
+                    if(type.GetSuperclassDefinition(typeof(DynamicEditorControl<,>)) is Type editorClass)
+                    {
+                        valueType = editorClass.GenericTypeArguments[0];
+                        editor = editorClass.GenericTypeArguments[1];
+                    }
+                    else if(type.GetSuperclassDefinition(typeof(DynamicEnclosedEditorControl<,>)) is Type enclosedEditorClass)
+                    {
+                        valueType = enclosedEditorClass.GenericTypeArguments[0];
+                        editor = enclosedEditorClass.GenericTypeArguments[1];
+                    }
+                    if (editor is not null && valueType is not null && (editor == typeof(IBaseEditor) || editor.HasInterface<IBaseEditor>()))
                     {
                         _editors.GetValueOrAdd(editor).Add((valueType, type));
                     }