JsUuid.cs 755 B

12345678910111213141516171819202122232425
  1. using System;
  2. using Jint.Native;
  3. namespace Jint.Tests.Runtime.Domain
  4. {
  5. public sealed class JsUuid : JsValue, IEquatable<JsUuid>
  6. {
  7. internal readonly Guid _value;
  8. public static readonly JsUuid Empty = new JsUuid(Guid.Empty);
  9. public JsUuid(Guid value) : base(Jint.Runtime.Types.String) => _value = value;
  10. public static implicit operator JsUuid(Guid g) => new JsUuid(g);
  11. public override bool Equals(JsValue other) => Equals(other as JsUuid);
  12. public bool Equals(JsUuid other) => other?._value == _value;
  13. public override int GetHashCode() => _value.GetHashCode();
  14. public override object ToObject() => _value;
  15. public override string ToString() => _value.ToString();
  16. }
  17. }