mirror of
https://github.com/ZuneDev/ZuneUIXTools.git
synced 2026-07-27 13:11:59 -07:00
Fix crashes due to EnumerableEditorView being used on inappropriate types
This commit is contained in:
@@ -21,9 +21,10 @@ public class EnumerableEditorViewModel : EditorBase<IEnumerable>, ILabelledInspe
|
|||||||
|
|
||||||
public override bool IsReadOnly => Value is IList collection && collection.IsReadOnly;
|
public override bool IsReadOnly => Value is IList collection && collection.IsReadOnly;
|
||||||
|
|
||||||
public IEnumerable<InspectorViewModel> Inspectables => Value
|
public IEnumerable<InspectorViewModel> Inspectables => Value?
|
||||||
.Cast<object>()
|
.Cast<object>()
|
||||||
.Select(inst => new InspectorViewModel() { SelectedObject = Builder(inst) });
|
.Select(inst => new InspectorViewModel() { SelectedObject = Builder(inst) })
|
||||||
|
?? Array.Empty<InspectorViewModel>();
|
||||||
|
|
||||||
private static InspectableObject DefaultBuilder(object instance)
|
private static InspectableObject DefaultBuilder(object instance)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Collections;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ZuneUIXTools.Modules.Inspectors;
|
namespace ZuneUIXTools.Modules.Inspectors;
|
||||||
@@ -7,6 +8,8 @@ public class EnumerablePropertyEditorBuilder : InheritablePropertyEditorBuilder<
|
|||||||
{
|
{
|
||||||
public override bool IsApplicable(PropertyDescriptor propertyDescriptor)
|
public override bool IsApplicable(PropertyDescriptor propertyDescriptor)
|
||||||
{
|
{
|
||||||
return base.IsApplicable(propertyDescriptor) && propertyDescriptor.PropertyType != typeof(string);
|
return base.IsApplicable(propertyDescriptor)
|
||||||
|
&& propertyDescriptor.PropertyType != typeof(string)
|
||||||
|
&& !propertyDescriptor.PropertyType.IsAssignableTo(typeof(JToken));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user