JsNull.cs 745 B

12345678910111213141516171819202122232425262728
  1. using System.Runtime.CompilerServices;
  2. using Jint.Runtime;
  3. namespace Jint.Native;
  4. public sealed class JsNull : JsValue, IEquatable<JsNull>
  5. {
  6. internal JsNull() : base(Types.Null)
  7. {
  8. }
  9. public override object? ToObject() => null;
  10. public override string ToString() => "null";
  11. protected internal override bool IsLooselyEqual(JsValue value)
  12. {
  13. return ReferenceEquals(Null, value) || ReferenceEquals(Undefined, value);
  14. }
  15. public override bool Equals(object? obj) => Equals(obj as JsNull);
  16. public override bool Equals(JsValue? other) => Equals(other as JsNull);
  17. public bool Equals(JsNull? other) => other is not null;
  18. public override int GetHashCode() => RuntimeHelpers.GetHashCode(this);
  19. }