diff --git a/src/core-taggeds-optional/Optional/Optional.T.Comparer/Optional.T.Comparer.cs b/src/core-taggeds-optional/Optional/Optional.T.Comparer/Optional.T.Comparer.cs deleted file mode 100644 index 3fe501ec..00000000 --- a/src/core-taggeds-optional/Optional/Optional.T.Comparer/Optional.T.Comparer.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections.Generic; - -namespace System; - -partial struct Optional -{ - // TODO: Add the tests and open the class - internal sealed class Comparer : IComparer> - { - private readonly IComparer comparer; - - private Comparer(IComparer comparer) - => - this.comparer = comparer; - - public static Comparer Create(IComparer comparer) - => - new(comparer ?? throw new ArgumentNullException(nameof(comparer))); - - public int Compare(Optional x, Optional y) - => - x.InternalCompareTo(y, comparer); - } -} diff --git a/src/core-taggeds-optional/Optional/Optional.T/Optional.T.Comparison.Internal.cs b/src/core-taggeds-optional/Optional/Optional.T/Internal.Comparison/Optional.T.InternalCompareTo.cs similarity index 100% rename from src/core-taggeds-optional/Optional/Optional.T/Optional.T.Comparison.Internal.cs rename to src/core-taggeds-optional/Optional/Optional.T/Internal.Comparison/Optional.T.InternalCompareTo.cs diff --git a/src/core-taggeds-optional/Optional/Optional.T/Internal.Comparison/Optional.T.InternalComparer.cs b/src/core-taggeds-optional/Optional/Optional.T/Internal.Comparison/Optional.T.InternalComparer.cs new file mode 100644 index 00000000..b54e8db9 --- /dev/null +++ b/src/core-taggeds-optional/Optional/Optional.T/Internal.Comparison/Optional.T.InternalComparer.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; + +namespace System; + +partial struct Optional +{ + internal sealed class InternalComparer(IComparer comparer) : IComparer> + { + public int Compare(Optional x, Optional y) + => + x.InternalCompareTo(y, comparer); + } +} diff --git a/src/core-taggeds-optional/Optional/Optional.T/Optional.T.Comparison.cs b/src/core-taggeds-optional/Optional/Optional.T/Optional.T.Comparison.cs new file mode 100644 index 00000000..1405373f --- /dev/null +++ b/src/core-taggeds-optional/Optional/Optional.T/Optional.T.Comparison.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace System; + +partial struct Optional +{ + // TODO: Add the tests and open the method + internal static IComparer> CreateComparer(IComparer comparer) + => + new InternalComparer(comparer ?? throw new ArgumentNullException(nameof(comparer))); +} diff --git a/src/core-taggeds-optional/Optional/Optional/Optional.Comparison.cs b/src/core-taggeds-optional/Optional/Optional/Optional.Comparison.cs index 0216688b..61560937 100644 --- a/src/core-taggeds-optional/Optional/Optional/Optional.Comparison.cs +++ b/src/core-taggeds-optional/Optional/Optional/Optional.Comparison.cs @@ -1,4 +1,6 @@ -namespace System; +using System.Collections.Generic; + +namespace System; partial class Optional { @@ -7,4 +9,9 @@ internal static int Compare(Optional left, Optional right) where T : IComparable => left.CompareTo(right); + + // TODO: Add the tests and open the method + internal static IComparer> CreateComparer(IComparer comparer) + => + new Optional.InternalComparer(comparer ?? throw new ArgumentNullException(nameof(comparer))); }