Integrates validators into drawers pipeline

This commit is contained in:
VladV 2022-05-19 17:20:15 +03:00
parent 5845f1758a
commit 801b793124
5 changed files with 32 additions and 5 deletions

View File

@ -36,11 +36,6 @@ namespace TriInspector.Elements
element = drawer.CreateElementInternal(property, element); element = drawer.CreateElementInternal(property, element);
} }
if (property.HasValidators)
{
AddChild(new TriPropertyValidationResultElement(property));
}
AddChild(element); AddChild(element);
} }

View File

@ -4,6 +4,7 @@
{ {
public const int System = -9999; public const int System = -9999;
public const int Inspector = -2000; public const int Inspector = -2000;
public const int Validator = -1500;
public const int Decorator = -1000; public const int Decorator = -1000;
public const int Drawer = 0; public const int Drawer = 0;
public const int Fallback = 9999; public const int Fallback = 9999;

View File

@ -152,6 +152,14 @@ namespace TriInspector
_drawersBackingField = Enumerable.Empty<TriCustomDrawer>() _drawersBackingField = Enumerable.Empty<TriCustomDrawer>()
.Concat(TriDrawersUtilities.CreateValueDrawersFor(FieldType)) .Concat(TriDrawersUtilities.CreateValueDrawersFor(FieldType))
.Concat(TriDrawersUtilities.CreateAttributeDrawersFor(Attributes)) .Concat(TriDrawersUtilities.CreateAttributeDrawersFor(Attributes))
.Concat(new[]
{
new ValidatorsDrawer
{
Order = TriDrawerOrder.Validator,
ApplyOnArrayElement = true,
},
})
.Where(it => CanApplyOn(this, it.ApplyOnArrayElement)) .Where(it => CanApplyOn(this, it.ApplyOnArrayElement))
.OrderBy(it => it.Order) .OrderBy(it => it.Order)
.ToList(); .ToList();

View File

@ -0,0 +1,20 @@
using TriInspector.Elements;
namespace TriInspector
{
internal class ValidatorsDrawer : TriCustomDrawer
{
public override TriElement CreateElementInternal(TriProperty property, TriElement next)
{
if (!property.HasValidators)
{
return next;
}
var element = new TriElement();
element.AddChild(new TriPropertyValidationResultElement(property));
element.AddChild(next);
return element;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 70da4f7e93ab42ffa7b39c465d2d33e1
timeCreated: 1652969657