50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
using Qrakhen.Qamp.Core.Execution;
|
|
using Qrakhen.Qamp.Core.Values.Objects;
|
|
|
|
namespace Qrakhen.Qamp.Core.Values;
|
|
|
|
internal static class ValueExtensions
|
|
{
|
|
public static Value ToValue(this object obj)
|
|
{
|
|
if (obj is sbyte _byte)
|
|
return new Value((long)_byte);
|
|
if (obj is short _short)
|
|
return new Value((long)_short);
|
|
if (obj is int _int)
|
|
return new Value((long)_int);
|
|
if (obj is long _long)
|
|
return new Value(_long);
|
|
|
|
if (obj is byte _sbyte)
|
|
return new Value((ulong)_sbyte);
|
|
if (obj is ushort _ushort)
|
|
return new Value((ulong)_ushort);
|
|
if (obj is uint _uint)
|
|
return new Value((ulong)_uint);
|
|
if (obj is ulong _ulong)
|
|
return new Value((ulong)_ulong);
|
|
|
|
if (obj is bool _bool)
|
|
return new Value(_bool);
|
|
if (obj is char _char)
|
|
return new Value(_char);
|
|
if (obj is string _string)
|
|
return Objects.String.Make(_string);
|
|
|
|
if (obj is float _float)
|
|
return new Value(_float);
|
|
if (obj is double _double)
|
|
return new Value(_double);
|
|
|
|
if (obj is Obj _obj)
|
|
return Obj.Create(_obj);
|
|
|
|
throw new QampException($"Could not convert native system value {obj} to qamp value.");
|
|
}
|
|
|
|
public static object ToObject(this Value value)
|
|
{
|
|
|
|
}
|
|
} |