Skip to content

Commit

Permalink
Adding the file headers
Browse files Browse the repository at this point in the history
  • Loading branch information
dgmjr committed Apr 19, 2024
1 parent fef2d21 commit dfec90a
Show file tree
Hide file tree
Showing 24 changed files with 210 additions and 98 deletions.
20 changes: 10 additions & 10 deletions Logging/StaticLogger.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
namespace Microsoft.Extensions.Logging;

using Serilog;
using Serilog.Extensions.Logging;
using Serilog.Extensions.Hosting;

using Log = Serilog.Log;
using SeriloggerFactory = Serilog.Extensions.Logging.SerilogLoggerFactory;

using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;

using Serilog;
using Serilog.Core;
using Serilog.Events;
using Serilog.Extensions.Hosting;
using Serilog.Extensions.Logging;

using Log = Serilog.Log;
using SeriloggerFactory = Serilog.Extensions.Logging.SerilogLoggerFactory;

public static class StaticLogger
{
Expand All @@ -27,14 +27,14 @@ public static class StaticLogger
>(
key =>
(
Factory.CreateLogger(key.FullName ?? key.Name)
Factory.CreateLogger(key.GetDisplayName() ?? key.Name)
?? throw new InvalidOperationException("Logger creation failed")
)!
);

public static readonly ILoggerFactory Factory = new SeriloggerFactory(NewSerilogger());
private static readonly ILoggerFactory Factory = new SeriloggerFactory(NewSerilogger());

public static ILogger<T> GetLogger<T>() => Factory.CreateLogger<T>();
public static ILogger<T> GetLogger<T>() => new Logger<T>(Factory);

public static ILogger GetLogger([CallerMemberName] string? name = default) => Loggers[name];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,27 @@
*/
// Documentation for CaseInsensitiveKeyDictionary

using System.Linq; // Using directive for LINQ functionality

namespace System.Collections.Generic; // Namespace declaration for the custom class

using System.Linq; // Using directive for LINQ functionality

public class CaseInsensitiveKeyDictionary<TValue> : Dictionary<string, TValue>
{
/// <summary>
/// Initializes a new instance of the CaseInsensitiveKeyDictionary class that is empty.
/// </summary>
public CaseInsensitiveKeyDictionary() : this(Enumerable.Empty<KeyValuePair<string, TValue>>()) { }
public CaseInsensitiveKeyDictionary()
: this(Enumerable.Empty<KeyValuePair<string, TValue>>()) { }

/// <summary>
/// Initializes a new instance of the CaseInsensitiveKeyDictionary class with the specified original key-value pairs.
/// </summary>
/// <param name="original">The original key-value pairs to initialize the dictionary with.</param>
public CaseInsensitiveKeyDictionary(IEnumerable<KeyValuePair<string, TValue>> original)
: base(original.ToDictionary(kvp => kvp.Key, kvp => kvp.Value), StringComparer.OrdinalIgnoreCase)
: base(
original.ToDictionary(kvp => kvp.Key, kvp => kvp.Value),
StringComparer.OrdinalIgnoreCase
)
{
// Calls the base class constructor (Dictionary) to populate the dictionary
// Key comparison is done in a case-insensitive manner using StringComparer.OrdinalIgnoreCase
Expand Down
13 changes: 5 additions & 8 deletions System/System.Text.Json/DictionaryStringJsonConverter.cs
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;
Expand Down
14 changes: 14 additions & 0 deletions System/System.Text.Json/JsonConverterAttribute.cs
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;
}
}
6 changes: 0 additions & 6 deletions System/System.Text.Json/JsonUnixTimeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,3 @@ Jso options
public override void Write(Utf8JsonWriter writer, DateTimeOffset value, Jso options) =>
writer.WriteNumberValue(value.ToUnixTimeMilliseconds());
}

public class JsonConverterAttribute<T> : JConverterAttribute
{
public JsonConverterAttribute()
: base(typeof(T)) { }
}
9 changes: 9 additions & 0 deletions System/System/Box.cs
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>
Expand Down
9 changes: 9 additions & 0 deletions System/System/EnumExtensions.cs
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;
Expand Down
10 changes: 10 additions & 0 deletions System/System/Enums.cs
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
Expand All @@ -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
{
Expand Down
9 changes: 9 additions & 0 deletions System/System/EnvironmentExtensions.cs
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
Expand Down
13 changes: 5 additions & 8 deletions System/System/FlagsExtensions.cs
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;
Expand Down
16 changes: 14 additions & 2 deletions System/System/GuidOrString.cs
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) { }
}
9 changes: 9 additions & 0 deletions System/System/HashCode.cs
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.
Expand Down
20 changes: 8 additions & 12 deletions System/System/ICloneable{TSelf}.cs
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;

Expand Down
13 changes: 5 additions & 8 deletions System/System/IComplex.cs
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;
Expand Down
19 changes: 15 additions & 4 deletions System/System/JsonIntegerToTimeSpanConverter.cs
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;
Expand All @@ -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);
}
9 changes: 9 additions & 0 deletions System/System/JsonUriStringConverter.cs
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>
Expand Down
15 changes: 5 additions & 10 deletions System/System/Math.cs
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;
Expand Down
9 changes: 9 additions & 0 deletions System/System/ObjectExtensions.cs
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
Expand Down
25 changes: 18 additions & 7 deletions System/System/ObjectOrString.cs
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)
{
Expand All @@ -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();

Expand Down
Loading

0 comments on commit dfec90a

Please sign in to comment.