From 9a33ce6748b66ed5e75a177b1061d07e7c67a270 Mon Sep 17 00:00:00 2001 From: BEN ABT Date: Thu, 11 Jan 2024 17:02:11 +0100 Subject: [PATCH] add interface stuff for guids --- src/StrongOf/IStrongGuid.cs | 25 +++++++++++++++++++++++++ src/StrongOf/StrongGuid.cs | 6 +++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/StrongOf/IStrongGuid.cs b/src/StrongOf/IStrongGuid.cs index 48b5f27..6d483dd 100644 --- a/src/StrongOf/IStrongGuid.cs +++ b/src/StrongOf/IStrongGuid.cs @@ -14,4 +14,29 @@ public interface IStrongGuid : IStrongOf /// Returns the value of the strong type as a Guid. /// Guid AsGuid(); + + /// + /// Checks if the Guid is empty. + /// + /// True if the Guid is empty; otherwise, false. + bool IsEmpty(); + + /// + /// Converts the value of this instance to its equivalent string representation using the specified format. + /// + /// A standard or custom format string. + /// The string representation of the value of this instance as specified by format. + string ToString(string format); + + /// + /// Converts the value of this instance to its equivalent string representation with dashes. + /// + /// The string representation of the value of this instance with dashes. + string ToStringWithDashes(); + + /// + /// Converts the value of this instance to its equivalent string representation without dashes. + /// + /// The string representation of the value of this instance without dashes. + string ToStringWithoutDashes(); } diff --git a/src/StrongOf/StrongGuid.cs b/src/StrongOf/StrongGuid.cs index acfd331..4f2e67f 100644 --- a/src/StrongOf/StrongGuid.cs +++ b/src/StrongOf/StrongGuid.cs @@ -80,7 +80,7 @@ public int CompareTo(object? other) /// /// An empty Guid of the strong type. public static TStrong Empty() - => StrongOf.From(Guid.Empty); + => From(Guid.Empty); /// /// Checks if the Guid is empty. @@ -94,7 +94,7 @@ public bool IsEmpty() /// /// A new Guid of the strong type. public static TStrong New() - => StrongOf.From(Guid.NewGuid()); + => From(Guid.NewGuid()); /// /// Tries to parse a Guid from a string and returns a value that indicates whether the operation succeeded. @@ -106,7 +106,7 @@ public static bool TryParse(ReadOnlySpan content, [NotNullWhen(true)] out { if (Guid.TryParse(content, out Guid value)) { - strong = StrongOf.From(value); + strong = From(value); return true; }