-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
210 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
/* | ||
* DictionaryStringJsonConverter.cs | ||
* | ||
* Created: 2024-56-20T05:56:46-05:00 | ||
* Modified: 2024-56-20T05:56:46-05:00 | ||
* | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* | ||
* Copyright © 2024 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
* Created: 2024-56-20T05:56:46-05:00 | ||
* Modified: 2024-27-19T13:27:28-04:00 | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* Copyright: © 2022 - 2024 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
namespace System.Text.Json; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
|
||
namespace System.Text.Json; | ||
|
||
public class JsonConverterAttribute<T>(params object[] converterParameters) | ||
: JConverterAttribute(typeof(T)) | ||
{ | ||
public object[] ConverterParameters { get; init; } = converterParameters; | ||
|
||
public override JConverter? CreateConverter(type typeToConvert) | ||
{ | ||
return Activator.CreateInstance(ConverterType, ConverterParameters) as JConverter; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
/* | ||
* Box.cs | ||
* Created: 2024-01-16T18:01:13-04:00 | ||
* Modified: 2024-31-19T13:31:54-04:00 | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* Copyright: © 2022 - 2024 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
namespace System; | ||
|
||
public class Box<T> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
/* | ||
* EnumExtensions.cs | ||
* Created: 2024-19-20T15:19:44-05:00 | ||
* Modified: 2024-27-19T13:27:43-04:00 | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* Copyright: © 2022 - 2024 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
namespace System; | ||
|
||
using System.ComponentModel.DataAnnotations; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
/* | ||
* Enums.cs | ||
* Created: 2024-48-26T01:48:06-05:00 | ||
* Modified: 2024-27-19T13:27:55-04:00 | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* Copyright: © 2022 - 2024 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
namespace System; | ||
|
||
public static class Enums | ||
|
@@ -7,6 +16,7 @@ public static T[] GetValues<T>() | |
{ | ||
return Enum.GetValues(typeof(T)).OfType<T>().ToArray(); | ||
} | ||
|
||
public static T Parse<T>(string s) | ||
where T : Enum | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
/* | ||
* EnvironmentExtensions.cs | ||
* Created: 2024-36-09T06:36:02-05:00 | ||
* Modified: 2024-32-19T13:32:03-04:00 | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* Copyright: © 2022 - 2024 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
namespace System; | ||
|
||
public static class EnvironmentExtensions | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
/* | ||
* FlagsExtensions.cs | ||
* | ||
* Created: 2024-08-19T08:08:09-05:00 | ||
* Modified: 2024-08-19T08:08:09-05:00 | ||
* | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* | ||
* Copyright © 2024 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
* Created: 2024-08-19T08:08:09-05:00 | ||
* Modified: 2024-28-19T13:28:28-04:00 | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* Copyright: © 2022 - 2024 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
namespace System; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
/* | ||
* GuidOrString.cs | ||
* Created: 2024-18-08T02:18:13-05:00 | ||
* Modified: 2024-29-19T13:29:07-04:00 | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* Copyright: © 2022 - 2024 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
namespace System; | ||
|
||
public class GuidOrString : TOrString<GuidOrString, guid> | ||
{ | ||
public GuidOrString(string str) : base(str) { } | ||
public GuidOrString(guid guid) : base(guid) { } | ||
public GuidOrString(string str) | ||
: base(str) { } | ||
|
||
public GuidOrString(guid guid) | ||
: base(guid) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
/* | ||
* HashCode.cs | ||
* Created: 2023-30-14T18:30:21-04:00 | ||
* Modified: 2024-29-19T13:29:14-04:00 | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* Copyright: © 2022 - 2024 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
#if !NETSTANDARD2_1_OR_GREATER | ||
using System; | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
// | ||
// ICloneable.cs | ||
// | ||
// Created: 2022-10-23-11:39:49 | ||
// Modified: 2022-11-11-06:11:07 | ||
// | ||
// Author: David G. Moore, Jr. <[email protected]> | ||
// | ||
// Copyright © 2022-2023 David G. Moore, Jr., All Rights Reserved | ||
// License: MIT (https://opensource.org/licenses/MIT) | ||
// | ||
|
||
/* | ||
* ICloneable{TSelf}.cs | ||
* Created: 2023-30-14T18:30:21-04:00 | ||
* Modified: 2024-29-19T13:29:23-04:00 | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* Copyright: © 2022 - 2024 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
namespace System; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
/* | ||
* IComplex.cs | ||
* | ||
* Created: 2023-09-21-08:09:26 | ||
* Modified: 2023-10-02-04:54:32 | ||
* | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* | ||
* Copyright © 2022 - 2023 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
* Created: 2023-09-21T20:09:26-04:00 | ||
* Modified: 2024-29-19T13:29:29-04:00 | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* Copyright: © 2022 - 2024 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
namespace System.Numerics; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
/* | ||
* JsonIntegerToTimeSpanConverter.cs | ||
* Created: 2023-23-22T07:23:06-05:00 | ||
* Modified: 2024-29-19T13:29:34-04:00 | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* Copyright: © 2022 - 2024 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
namespace System; | ||
|
||
using System.Text.Json.Serialization; | ||
|
@@ -6,9 +15,11 @@ namespace System; | |
|
||
public class JsonIntegerToTimeSpanConverter : JsonConverter<duration> | ||
{ | ||
public override duration Read(ref Utf8JsonReader reader, type typeToConvert, Jso options) | ||
=> reader.TokenType != JTokenType.Number ? throw new JsonException() : duration.FromSeconds(reader.GetInt64()); | ||
public override duration Read(ref Utf8JsonReader reader, type typeToConvert, Jso options) => | ||
reader.TokenType != JTokenType.Number | ||
? throw new JsonException() | ||
: duration.FromSeconds(reader.GetInt64()); | ||
|
||
public override void Write(Utf8JsonWriter writer, duration value, Jso options) | ||
=> writer.WriteNumberValue(value.TotalSeconds); | ||
public override void Write(Utf8JsonWriter writer, duration value, Jso options) => | ||
writer.WriteNumberValue(value.TotalSeconds); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
/* | ||
* JsonUriStringConverter.cs | ||
* Created: 2023-46-22T02:46:39-05:00 | ||
* Modified: 2024-29-19T13:29:48-04:00 | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* Copyright: © 2022 - 2024 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
namespace System; | ||
|
||
public class JsonUriStringConverter : System.Text.Json.Serialization.JsonConverter<Uri> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
/* | ||
* | ||
* Math.cs | ||
* | ||
* Created: 2022-11-12-07:23:53 | ||
* Modified: 2022-11-12-07:25:59 | ||
* | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* | ||
* Copyright © 2022-2023 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
* | ||
* Created: 2023-30-14T18:30:21-04:00 | ||
* Modified: 2024-29-19T13:29:57-04:00 | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* Copyright: © 2022 - 2024 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
namespace System; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
/* | ||
* ObjectExtensions.cs | ||
* Created: 2024-06-23T03:06:18-05:00 | ||
* Modified: 2024-30-19T13:30:07-04:00 | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* Copyright: © 2022 - 2024 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
namespace System; | ||
|
||
public static class ObjectExtensions | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
namespace System; | ||
/* | ||
* ObjectOrString.cs | ||
* Created: 2024-11-08T02:11:30-05:00 | ||
* Modified: 2024-30-19T13:30:13-04:00 | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* Copyright: © 2022 - 2024 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
using OneOf; | ||
namespace System; | ||
|
||
public abstract class TOrString<TSelf, T> where TSelf : TOrString<TSelf, T> | ||
public abstract class TOrString<TSelf, T> | ||
where TSelf : TOrString<TSelf, T> | ||
{ | ||
protected TOrString(string str) | ||
{ | ||
|
@@ -22,13 +30,16 @@ protected TOrString(T t) | |
public bool IsT => AsT is not null; | ||
public bool IsString => String != null; | ||
|
||
public static implicit operator TOrString<TSelf, T>(T t) => | ||
(Activator.CreateInstance(typeof(TSelf), t) as TSelf)!; | ||
|
||
public static implicit operator TOrString<TSelf, T>(T t) => (Activator.CreateInstance(typeof(TSelf), t) as TSelf)!; | ||
|
||
public static implicit operator TOrString<TSelf, T>(string str) => (Activator.CreateInstance(typeof(TSelf), str) as TSelf)!; | ||
public static implicit operator TOrString<TSelf, T>(string str) => | ||
(Activator.CreateInstance(typeof(TSelf), str) as TSelf)!; | ||
|
||
public static implicit operator T(TOrString<TSelf, T> tOrString) => | ||
tOrString.IsT ? tOrString.AsT! : (Activator.CreateInstance(typeof(TSelf), tOrString) as TSelf)!; | ||
tOrString.IsT | ||
? tOrString.AsT! | ||
: (Activator.CreateInstance(typeof(TSelf), tOrString) as TSelf)!; | ||
|
||
public static explicit operator string(TOrString<TSelf, T> tOrString) => tOrString.ToString(); | ||
|
||
|
Oops, something went wrong.