Skip to content

Commit

Permalink
Merge pull request #10 from BenjaminAbt/feature/add-interface-guid
Browse files Browse the repository at this point in the history
add interface stuff for guids
  • Loading branch information
BenjaminAbt committed Jan 11, 2024
2 parents 0d6be33 + 9a33ce6 commit 2ce0cb5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
25 changes: 25 additions & 0 deletions src/StrongOf/IStrongGuid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,29 @@ public interface IStrongGuid : IStrongOf
/// Returns the value of the strong type as a Guid.
/// </summary>
Guid AsGuid();

/// <summary>
/// Checks if the Guid is empty.
/// </summary>
/// <returns>True if the Guid is empty; otherwise, false.</returns>
bool IsEmpty();

/// <summary>
/// Converts the value of this instance to its equivalent string representation using the specified format.
/// </summary>
/// <param name="format">A standard or custom format string.</param>
/// <returns>The string representation of the value of this instance as specified by format.</returns>
string ToString(string format);

/// <summary>
/// Converts the value of this instance to its equivalent string representation with dashes.
/// </summary>
/// <returns>The string representation of the value of this instance with dashes.</returns>
string ToStringWithDashes();

/// <summary>
/// Converts the value of this instance to its equivalent string representation without dashes.
/// </summary>
/// <returns>The string representation of the value of this instance without dashes.</returns>
string ToStringWithoutDashes();
}
6 changes: 3 additions & 3 deletions src/StrongOf/StrongGuid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public int CompareTo(object? other)
/// </summary>
/// <returns>An empty Guid of the strong type.</returns>
public static TStrong Empty()
=> StrongOf<Guid, TStrong>.From(Guid.Empty);
=> From(Guid.Empty);

/// <summary>
/// Checks if the Guid is empty.
Expand All @@ -94,7 +94,7 @@ public bool IsEmpty()
/// </summary>
/// <returns>A new Guid of the strong type.</returns>
public static TStrong New()
=> StrongOf<Guid, TStrong>.From(Guid.NewGuid());
=> From(Guid.NewGuid());

/// <summary>
/// Tries to parse a Guid from a string and returns a value that indicates whether the operation succeeded.
Expand All @@ -106,7 +106,7 @@ public static bool TryParse(ReadOnlySpan<char> content, [NotNullWhen(true)] out
{
if (Guid.TryParse(content, out Guid value))
{
strong = StrongOf<Guid, TStrong>.From(value);
strong = From(value);
return true;
}

Expand Down

0 comments on commit 2ce0cb5

Please sign in to comment.