21 lines
487 B
C#
21 lines
487 B
C#
|
|
using System.Diagnostics.CodeAnalysis;
|
||
|
|
using Jint;
|
||
|
|
using Jint.Native;
|
||
|
|
using Jint.Runtime.Interop;
|
||
|
|
|
||
|
|
namespace Elsa.Scripting.JavaScript.ObjectConverters;
|
||
|
|
|
||
|
|
internal class EnumToStringConverter : IObjectConverter
|
||
|
|
{
|
||
|
|
public bool TryConvert(Engine engine, object value, [NotNullWhen(true)] out JsValue? result)
|
||
|
|
{
|
||
|
|
if (value is Enum)
|
||
|
|
{
|
||
|
|
result = value.ToString();
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
result = JsValue.Null;
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|