2022-06-06 07:17:53 -04:00
|
|
|
|
using System;
|
|
|
|
|
using JetBrains.Annotations;
|
2022-06-03 08:16:23 -04:00
|
|
|
|
|
|
|
|
|
namespace TriInspector
|
|
|
|
|
{
|
|
|
|
|
public abstract class TriPropertyExtension
|
|
|
|
|
{
|
|
|
|
|
public bool? ApplyOnArrayElement { get; internal set; }
|
|
|
|
|
|
|
|
|
|
[PublicAPI]
|
2022-06-06 07:17:53 -04:00
|
|
|
|
public virtual TriExtensionInitializationResult Initialize(TriPropertyDefinition propertyDefinition)
|
2022-06-03 08:16:23 -04:00
|
|
|
|
{
|
2022-06-06 07:17:53 -04:00
|
|
|
|
return TriExtensionInitializationResult.Ok;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public readonly struct TriExtensionInitializationResult
|
|
|
|
|
{
|
|
|
|
|
public TriExtensionInitializationResult(bool shouldApply, string errorMessage)
|
|
|
|
|
{
|
|
|
|
|
ShouldApply = shouldApply;
|
|
|
|
|
ErrorMessage = errorMessage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool ShouldApply { get; }
|
|
|
|
|
public string ErrorMessage { get; }
|
|
|
|
|
public bool IsError => ErrorMessage != null;
|
|
|
|
|
|
|
|
|
|
[PublicAPI]
|
|
|
|
|
public static TriExtensionInitializationResult Ok => new TriExtensionInitializationResult(true, null);
|
|
|
|
|
|
|
|
|
|
[PublicAPI]
|
|
|
|
|
public static TriExtensionInitializationResult Skip => new TriExtensionInitializationResult(false, null);
|
|
|
|
|
|
|
|
|
|
[PublicAPI]
|
|
|
|
|
public static TriExtensionInitializationResult Error([NotNull] string errorMessage)
|
|
|
|
|
{
|
|
|
|
|
if (errorMessage == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException(nameof(errorMessage));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new TriExtensionInitializationResult(false, errorMessage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[PublicAPI]
|
|
|
|
|
public static implicit operator TriExtensionInitializationResult(string errorMessage)
|
|
|
|
|
{
|
|
|
|
|
return Error(errorMessage);
|
2022-06-03 08:16:23 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|