JsUuid.cs 816 B

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