Add Initialize method for drawers, processors and validators

This commit is contained in:
VladV 2022-05-09 14:23:27 +03:00
parent 5a7b20958f
commit f819b0e46a
5 changed files with 48 additions and 1 deletions

View File

@ -1,10 +1,18 @@
namespace TriInspector
using JetBrains.Annotations;
namespace TriInspector
{
public abstract class TriCustomDrawer
{
internal int Order { get; set; }
internal bool ApplyOnArrayElement { get; set; }
[PublicAPI]
public virtual void Initialize(TriPropertyDefinition propertyDefinition)
{
}
[PublicAPI]
public virtual string CanDraw(TriProperty property)
{
return null;

View File

@ -91,6 +91,11 @@ namespace TriInspector
TriDrawersUtilities.CreateHideProcessorsFor(Attributes)
.Where(it => CanApplyOn(this, applyOnArrayElement: false))
.ToList();
foreach (var processor in _hideProcessorsBackingField)
{
processor.Initialize(this);
}
}
return _hideProcessorsBackingField;
@ -107,6 +112,11 @@ namespace TriInspector
TriDrawersUtilities.CreateDisableProcessorsFor(Attributes)
.Where(it => CanApplyOn(this, applyOnArrayElement: false))
.ToList();
foreach (var processor in _disableProcessorsBackingField)
{
processor.Initialize(this);
}
}
return _disableProcessorsBackingField;
@ -125,6 +135,11 @@ namespace TriInspector
.Where(it => CanApplyOn(this, it.ApplyOnArrayElement))
.OrderBy(it => it.Order)
.ToList();
foreach (var drawer in _drawersBackingField)
{
drawer.Initialize(this);
}
}
return _drawersBackingField;
@ -142,6 +157,11 @@ namespace TriInspector
.Concat(TriDrawersUtilities.CreateAttributeValidatorsFor(Attributes))
.Where(it => CanApplyOn(this, it.ApplyOnArrayElement))
.ToList();
foreach (var validator in _validatorsBackingField)
{
validator.Initialize(this);
}
}
return _validatorsBackingField;

View File

@ -1,4 +1,5 @@
using System;
using JetBrains.Annotations;
namespace TriInspector
{
@ -6,6 +7,12 @@ namespace TriInspector
{
internal Attribute RawAttribute { get; set; }
[PublicAPI]
public virtual void Initialize(TriPropertyDefinition propertyDefinition)
{
}
[PublicAPI]
public abstract bool IsDisabled(TriProperty property);
}

View File

@ -1,4 +1,5 @@
using System;
using JetBrains.Annotations;
namespace TriInspector
{
@ -6,6 +7,12 @@ namespace TriInspector
{
internal Attribute RawAttribute { get; set; }
[PublicAPI]
public virtual void Initialize(TriPropertyDefinition propertyDefinition)
{
}
[PublicAPI]
public abstract bool IsHidden(TriProperty property);
}

View File

@ -8,6 +8,11 @@ namespace TriInspector
{
internal bool ApplyOnArrayElement { get; set; }
[PublicAPI]
public virtual void Initialize(TriPropertyDefinition propertyDefinition)
{
}
[PublicAPI]
public abstract TriValidationResult Validate(TriProperty property);
}