Fix applyOnArrayElement

This commit is contained in:
VladV 2022-05-07 19:31:14 +03:00
parent 7dd7768132
commit 28cae2b146
2 changed files with 19 additions and 8 deletions

View File

@ -26,12 +26,6 @@ namespace TriInspector.Elements
{
var drawer = drawers[index];
if (_property.IsArrayElement && !drawer.ApplyOnArrayElement ||
_property.IsArray && drawer.ApplyOnArrayElement)
{
continue;
}
var canDrawMessage = drawer.CanDraw(_property);
if (!string.IsNullOrEmpty(canDrawMessage))
{

View File

@ -88,7 +88,9 @@ namespace TriInspector
if (_hideProcessorsBackingField == null)
{
_hideProcessorsBackingField =
TriDrawersUtilities.CreateHideProcessorsFor(Attributes).ToList();
TriDrawersUtilities.CreateHideProcessorsFor(Attributes)
.Where(it => CanApplyOn(this, applyOnArrayElement: false))
.ToList();
}
return _hideProcessorsBackingField;
@ -102,7 +104,9 @@ namespace TriInspector
if (_disableProcessorsBackingField == null)
{
_disableProcessorsBackingField =
TriDrawersUtilities.CreateDisableProcessorsFor(Attributes).ToList();
TriDrawersUtilities.CreateDisableProcessorsFor(Attributes)
.Where(it => CanApplyOn(this, applyOnArrayElement: false))
.ToList();
}
return _disableProcessorsBackingField;
@ -118,6 +122,7 @@ namespace TriInspector
_drawersBackingField = Enumerable.Empty<TriCustomDrawer>()
.Concat(TriDrawersUtilities.CreateValueDrawersFor(FieldType))
.Concat(TriDrawersUtilities.CreateAttributeDrawersFor(Attributes))
.Where(it => CanApplyOn(this, it.ApplyOnArrayElement))
.OrderBy(it => it.Order)
.ToList();
}
@ -135,6 +140,7 @@ namespace TriInspector
_validatorsBackingField = Enumerable.Empty<TriValidator>()
.Concat(TriDrawersUtilities.CreateValueValidatorsFor(FieldType))
.Concat(TriDrawersUtilities.CreateAttributeValidatorsFor(Attributes))
.Where(it => CanApplyOn(this, it.ApplyOnArrayElement))
.ToList();
}
@ -230,5 +236,16 @@ namespace TriInspector
{
return (self, obj, value) => { };
}
private static bool CanApplyOn(TriPropertyDefinition definition, bool applyOnArrayElement)
{
if (definition.IsArrayElement && !applyOnArrayElement ||
definition.IsArray && applyOnArrayElement)
{
return false;
}
return true;
}
}
}