diff --git a/SystemExtensions.NetCore/SystemExtensions.NetCore.csproj b/SystemExtensions.NetCore/SystemExtensions.NetCore.csproj
index 70a3f87..dfd1b66 100644
--- a/SystemExtensions.NetCore/SystemExtensions.NetCore.csproj
+++ b/SystemExtensions.NetCore/SystemExtensions.NetCore.csproj
@@ -8,7 +8,7 @@
System
LICENSE
true
- 1.8
+ 1.9
Alexandru Macocian
https://github.com/AlexMacocian/SystemExtensions
Extensions for the System namespace
diff --git a/SystemExtensions.NetStandard/Extensions/ObjectExtensions.cs b/SystemExtensions.NetStandard/Extensions/ObjectExtensions.cs
index 0035c12..02d7903 100644
--- a/SystemExtensions.NetStandard/Extensions/ObjectExtensions.cs
+++ b/SystemExtensions.NetStandard/Extensions/ObjectExtensions.cs
@@ -1,31 +1,7 @@
-using Newtonsoft.Json;
-
-namespace System.Extensions;
+namespace System.Extensions;
public static class ObjectExtensions
{
- public static T? Deserialize(this string serialized)
- where T : class
- {
- if (serialized.IsNullOrWhiteSpace())
- {
- throw new ArgumentException("Provided serialized string cannot be null or whitespace", nameof(serialized));
- }
-
- return JsonConvert.DeserializeObject(serialized);
- }
-
- public static string Serialize(this T obj)
- where T : class
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- return JsonConvert.SerializeObject(obj);
- }
-
public static T Cast(this object obj)
{
return (T)obj;
@@ -36,11 +12,6 @@ public static class ObjectExtensions
return obj as T;
}
- public static Optional ToOptional(this T obj)
- {
- return Optional.FromValue(obj);
- }
-
public static T ThrowIfNull([ValidatedNotNull] this T? obj, string name) where T : class
{
if (obj is null)
diff --git a/SystemExtensions.NetStandard/Extensions/Optional.cs b/SystemExtensions.NetStandard/Extensions/Optional.cs
deleted file mode 100644
index 6900288..0000000
--- a/SystemExtensions.NetStandard/Extensions/Optional.cs
+++ /dev/null
@@ -1,193 +0,0 @@
-namespace System.Extensions;
-
-public static class Optional
-{
- public static Optional None()
- {
- return new Optional.None();
- }
-
- public static Optional FromValue(T? value)
- {
- if (value == null)
- {
- return new Optional.None();
- }
-
- return new Optional.Some(value);
- }
-}
-
-public abstract class Optional : IEquatable>
-{
- public Optional(T value)
- {
- this.Value = value;
- }
-
- private T Value { get; }
-
- public T? ExtractValue()
- {
- if (this is None)
- {
- return default;
- }
- else
- {
- return this.Value;
- }
- }
- public Optional Do(Action? onSome, Action? onNone)
- {
- if (onSome is null)
- {
- throw new ArgumentNullException(nameof(onSome));
- }
-
- if (onNone is null)
- {
- throw new ArgumentNullException(nameof(onNone));
- }
-
- if (this is Some)
- {
- onSome.Invoke(this.Value);
- }
- else
- {
- onNone.Invoke();
- }
-
- return this;
- }
- public Optional DoAny(Action? onSome = default, Action? onNone = default)
- {
- if (this is Some)
- {
- onSome?.Invoke(this.Value);
- }
- else
- {
- onNone?.Invoke();
- }
-
- return this;
- }
- public Optional Switch(Func? onSome, Func? onNone)
- {
- if (onSome is null)
- {
- throw new ArgumentNullException($"{nameof(onSome)}");
- }
-
- if (onNone is null)
- {
- throw new ArgumentNullException($"{nameof(onNone)}");
- }
-
- if (this is Some)
- {
- return Optional.FromValue(onSome.Invoke(this.Value));
- }
- else
- {
- return Optional.FromValue(onNone.Invoke());
- }
- }
- public Optional SwitchAny(Func? onSome = null, Func? onNone = null)
- {
- if (this is Some)
- {
- return onSome != null ? Optional.FromValue(onSome.Invoke(this.Value)) : Optional.FromValue(default(V));
- }
- else
- {
- return onNone != null ? Optional.FromValue(onNone.Invoke()) : Optional.FromValue(default(V));
- }
- }
-
- public override bool Equals(object? obj)
- {
- if (obj is Optional)
- {
- return this.Equals(obj);
- }
-
- return base.Equals(obj);
- }
-
- public bool Equals(Optional? other)
- {
- if (this is Some && other is Some)
- {
- return this.As() is Some some ? some.Equals(other.As()) : false;
- }
-
- return false;
- }
-
- public static implicit operator Optional(T? value)
- {
- return Optional.FromValue(value);
- }
-
- public override int GetHashCode()
- {
- return this.Value == null ? base.GetHashCode() : this.Value.GetHashCode();
- }
-
- internal class Some : Optional, IEquatable
- {
- public Some(T value) : base(value)
- {
- }
-
- public override bool Equals(object? obj)
- {
- if (obj is Some)
- {
- return this.Equals(obj.As());
- }
-
- return base.Equals(obj);
- }
-
- public bool Equals(Some? other)
- {
- if (other is None)
- {
- return false;
- }
-
- if (other is not null)
- {
- return this.Value is not null && this.Value.Equals(other.Value);
- }
-
- return false;
- }
-
- public static bool operator ==(Some? left, Some right)
- {
- return left?.Equals(right) == true;
- }
-
- public static bool operator !=(Some? left, Some right)
- {
- return left?.Equals(right) != true;
- }
-
- public override int GetHashCode()
- {
- return this.Value is object ? this.Value.GetHashCode() : this.As