From a7e984cd9225bc2e0dc3b7e9a5f4eb7415f51622 Mon Sep 17 00:00:00 2001 From: Chris Jensen Date: Fri, 17 Sep 2021 11:50:23 +0200 Subject: [PATCH] IValueOf with static abstract From(TValue) at the cost of compatibility --- ValueOf/IValueOf.cs | 11 +++++++++++ ValueOf/ValueOf.cs | 4 ++-- ValueOf/ValueOf.csproj | 5 +++-- 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 ValueOf/IValueOf.cs diff --git a/ValueOf/IValueOf.cs b/ValueOf/IValueOf.cs new file mode 100644 index 0000000..b457eae --- /dev/null +++ b/ValueOf/IValueOf.cs @@ -0,0 +1,11 @@ +namespace ValueOf +{ + public interface IValueOf + { + static abstract TThis From(TValue item); + TValue Value { get; } + bool Equals(object obj); + int GetHashCode(); + string ToString(); + } +} \ No newline at end of file diff --git a/ValueOf/ValueOf.cs b/ValueOf/ValueOf.cs index b707102..01b2d10 100644 --- a/ValueOf/ValueOf.cs +++ b/ValueOf/ValueOf.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; @@ -6,7 +6,7 @@ namespace ValueOf { - public class ValueOf where TThis : ValueOf, new() + public class ValueOf : IValueOf where TThis : ValueOf, new() { private static readonly Func Factory; diff --git a/ValueOf/ValueOf.csproj b/ValueOf/ValueOf.csproj index 157e4c7..6c018ec 100644 --- a/ValueOf/ValueOf.csproj +++ b/ValueOf/ValueOf.csproj @@ -1,7 +1,8 @@ - + - net451;netcoreapp1.1;netstandard1.3 + net6.0 + preview Harry McIntyre ValueOf - Easy 'One-Liner' Value Objects for c#. Get over your Primitive Obsession! Harry McIntyre