mirror of
https://github.com/codewriter-packages/Tri-Inspector.git
synced 2025-01-22 08:18:49 -05:00
34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using TriInspector;
|
|
using TriInspector.Processors;
|
|
using TriInspector.Resolvers;
|
|
|
|
[assembly: RegisterTriPropertyHideProcessor(typeof(HideIfProcessor))]
|
|
|
|
namespace TriInspector.Processors
|
|
{
|
|
public class HideIfProcessor : TriPropertyHideProcessor<HideIfAttribute>
|
|
{
|
|
private ValueResolver<object> _conditionResolver;
|
|
|
|
public override TriExtensionInitializationResult Initialize(TriPropertyDefinition propertyDefinition)
|
|
{
|
|
base.Initialize(propertyDefinition);
|
|
|
|
_conditionResolver = ValueResolver.Resolve<object>(propertyDefinition, Attribute.Condition);
|
|
|
|
if (_conditionResolver.TryGetErrorString(out var error))
|
|
{
|
|
return error;
|
|
}
|
|
|
|
return TriExtensionInitializationResult.Ok;
|
|
}
|
|
|
|
public sealed override bool IsHidden(TriProperty property)
|
|
{
|
|
var val = _conditionResolver.GetValue(property);
|
|
var equal = val?.Equals(Attribute.Value) ?? Attribute.Value == null;
|
|
return equal != Attribute.Inverse;
|
|
}
|
|
}
|
|
} |