diff --git a/ExtensionsEx.cs b/ExtensionsEx.cs
index c6b4172..4dacd59 100644
--- a/ExtensionsEx.cs
+++ b/ExtensionsEx.cs
@@ -4,12 +4,27 @@
// Created : 27-08-2016
//
// Last Modified By : Frede H.
-// Last Modified On : 2021-02-24
+// Last Modified On : 12-31-2021
// ***********************************************************************
//
// Copyright © FCS 2015-2022
-//
-//
+//
+// Part of FCS.Lib - a set of utilities for C# - pieced together from fragments
+// Copyright (C) 2021 FCS
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
// ***********************************************************************
using System;
@@ -18,7 +33,7 @@ using System.Collections.Generic;
namespace FCS.Lib
{
///
- /// Class ExtensionsEx.
+ /// Class ExtensionsEx.
///
public static class ExtensionsEx
{
diff --git a/Generators.cs b/Generators.cs
index 4eddd79..bb31008 100644
--- a/Generators.cs
+++ b/Generators.cs
@@ -4,16 +4,16 @@
// Created : 2020-07-01
//
// Last Modified By : FH
-// Last Modified On : 2021-02-24
+// Last Modified On : 01-09-2022
// ***********************************************************************
-//
+//
// Copyright © FCS 2015-2022
//
-//
-// derived from https://sourceforge.net/projects/shorturl-dotnet
// Part of FCS.Lib - a set of utilities for C# - pieced together from fragments
// Copyright (C) 2021 FCS
//
+// Partly derived from https://sourceforge.net/projects/shorturl-dotnet/
+//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
@@ -26,7 +26,7 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-//
+
// ***********************************************************************
using System;
@@ -37,8 +37,8 @@ using System.Security.Cryptography;
namespace FCS.Lib
{
///
- /// Class Generators
- /// generates varioous kinds of random strings.
+ /// Class Generators
+ /// generates varioous kinds of random strings.
///
public static class Generators
{
@@ -56,7 +56,7 @@ namespace FCS.Lib
///
/// The lengt h.
/// System.String.
- /// derived from https://sourceforge.net/projects/shorturl-dotnet
+ ///
public static string ShortUrlGenerator(int length)
{
const string charsLower = "cdfghjkmnpqrstvwxyz";
@@ -129,8 +129,7 @@ namespace FCS.Lib
// If we processed the last character in this group, start over.
if (lastCharIdx == 0)
{
- charsLeftInGroup[nextGroupIdx] =
- charGroups[nextGroupIdx].Length;
+ charsLeftInGroup[nextGroupIdx] = charGroups[nextGroupIdx].Length;
}
// There are more unprocessed characters left.
else
@@ -297,7 +296,7 @@ namespace FCS.Lib
/// Randoms the seed.
///
/// Random.
- /// derived from https://sourceforge.net/projects/shorturl-dotnet/
+ /// derived from https://sourceforge.net/projects/shorturl-dotnet/
public static Random RandomSeed()
{
// As the default randomizer is based on the current time
diff --git a/IAsyncReadonlyRepo.cs b/IAsyncReadonlyRepo.cs
index 8c35b95..08ef9d1 100644
--- a/IAsyncReadonlyRepo.cs
+++ b/IAsyncReadonlyRepo.cs
@@ -4,12 +4,11 @@
// Created : 03-10-2015
//
// Last Modified By : FH
-// Last Modified On : 2021-03-27
+// Last Modified On : 12-31-2021
// ***********************************************************************
-//
+//
// Copyright © FCS 2015-2022
//
-//
// Part of FCS.Lib - a set of utilities for C# - pieced together from fragments
// Copyright (C) 2021 FCS
//
@@ -25,7 +24,7 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-//
+
// ***********************************************************************
using System;
@@ -37,7 +36,7 @@ using System.Threading.Tasks;
namespace FCS.Lib
{
///
- /// Interface IRepositoryAsync
+ /// Interface IRepositoryAsync
///
/// The type of the t entity.
public interface IAsyncReadonlyRepo where TEntity : class
diff --git a/IRepository.cs b/IRepository.cs
index b24187a..a07c890 100644
--- a/IRepository.cs
+++ b/IRepository.cs
@@ -4,12 +4,11 @@
// Created : 05-13-2020
//
// Last Modified By : FH
-// Last Modified On : 2021-02-24
+// Last Modified On : 12-31-2021
// ***********************************************************************
//
// Copyright © FCS 2015-2022
//
-//
// Part of FCS.Lib - a set of utilities for C# - pieced together from fragments
// Copyright (C) 2021 FCS
//
@@ -25,13 +24,13 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-//
+
// ***********************************************************************
namespace FCS.Lib
{
///
- /// Interface IRepository
+ /// Interface IRepository
///
///
/// The type of the TKey.
diff --git a/IRepositoryEx.cs b/IRepositoryEx.cs
index 07dadd4..dab5cf8 100644
--- a/IRepositoryEx.cs
+++ b/IRepositoryEx.cs
@@ -4,12 +4,11 @@
// Created : 03-10-2015
//
// Last Modified By : FH
-// Last Modified On : 2021-11-13
+// Last Modified On : 12-31-2021
// ***********************************************************************
//
// Copyright © FCS 2015-2022
//
-//
// Part of FCS.Lib - a set of utilities for C# - pieced together from fragments
// Copyright (C) 2021 FCS
//
@@ -25,7 +24,7 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-//
+
// ***********************************************************************
using System;
@@ -36,7 +35,7 @@ using System.Threading.Tasks;
namespace FCS.Lib
{
///
- /// Interface IRepositoryEx
+ /// Interface IRepositoryEx
///
/// The type of the t entity
public interface IRepositoryEx where TEntity : class
diff --git a/Mogrifiers.cs b/Mogrifiers.cs
index 18ea602..ddb5c38 100644
--- a/Mogrifiers.cs
+++ b/Mogrifiers.cs
@@ -4,12 +4,11 @@
// Created : 27-08-2016
//
// Last Modified By : Frede H.
-// Last Modified On : 2021-02-24
+// Last Modified On : 12-31-2021
// ***********************************************************************
//
// Copyright © FCS 2015-2022
//
-//
// Part of FCS.Lib - a set of utilities for C# - pieced together from fragments
// Copyright (C) 2021 FCS
//
@@ -25,7 +24,7 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-//
+
// ***********************************************************************
using System;
@@ -40,7 +39,7 @@ using System.Text.RegularExpressions;
namespace FCS.Lib
{
///
- /// Class Converters
+ /// Class Converters
///
public static class Mogrifiers
{
@@ -119,7 +118,7 @@ namespace FCS.Lib
/// T.
public static T IntToEnum(int value)
{
- return (T)Enum.ToObject(typeof(T), value);
+ return (T) Enum.ToObject(typeof(T), value);
}
///
@@ -171,7 +170,7 @@ namespace FCS.Lib
{
var empty = string.Empty;
if (list == null) return empty;
- var enumerator = (IEnumerator)list.GetType().GetMethod("GetEnumerator")?.Invoke(list, null);
+ var enumerator = (IEnumerator) list.GetType().GetMethod("GetEnumerator")?.Invoke(list, null);
while (enumerator != null && enumerator.MoveNext())
if (enumerator.Current != null)
empty = string.Concat(empty, enumerator.Current.ToString(), delimiter);
@@ -228,8 +227,8 @@ namespace FCS.Lib
return
!decimal.TryParse(inString.Replace(",", "").Replace(".", ""), NumberStyles.Number,
CultureInfo.InvariantCulture, out var num)
- ? null
- : decimal.Divide(num, new decimal((long)100));
+ ? (decimal?) null
+ : decimal.Divide(num, new decimal((long) 100));
}
///
@@ -240,7 +239,7 @@ namespace FCS.Lib
/// T.
public static T StringToEnum(string value)
{
- return (T)Enum.Parse(typeof(T), value, true);
+ return (T) Enum.Parse(typeof(T), value, true);
}
///
@@ -263,11 +262,6 @@ namespace FCS.Lib
/// List<T>.
/// value
/// delimiter
- /// value
- /// delimiter
- /// value
- /// delimiter
- /// value
public static List StringToList(string value, string delimiter)
{
if (string.IsNullOrEmpty(value)) throw new ArgumentNullException(nameof(value));
@@ -282,16 +276,16 @@ namespace FCS.Lib
var upperInvariant = o.ToUpperInvariant();
if (string.CompareOrdinal(upperInvariant, "system.string") == 0)
{
- ts.Add((T)Convert.ChangeType(str, typeof(T), CultureInfo.InvariantCulture));
+ ts.Add((T) Convert.ChangeType(str, typeof(T), CultureInfo.InvariantCulture));
}
else if (string.CompareOrdinal(upperInvariant, "system.int32") == 0)
{
- ts.Add((T)Convert.ChangeType(str, typeof(T), CultureInfo.InvariantCulture));
+ ts.Add((T) Convert.ChangeType(str, typeof(T), CultureInfo.InvariantCulture));
}
else if (string.CompareOrdinal(upperInvariant, "system.guid") == 0)
{
var guid = new Guid(str);
- ts.Add((T)Convert.ChangeType(guid, typeof(T), CultureInfo.InvariantCulture));
+ ts.Add((T) Convert.ChangeType(guid, typeof(T), CultureInfo.InvariantCulture));
}
}
@@ -338,12 +332,12 @@ namespace FCS.Lib
var dt = DateTime.UtcNow.ToString("yy MM dd HH MM ss");
var sb = new StringBuilder();
var dts = dt.Split(' ');
- sb.Append((char)int.Parse(dts[0]) + 65);
- sb.Append((char)int.Parse(dts[1]) + 65);
- sb.Append((char)int.Parse(dts[2]) + 97);
- sb.Append((char)int.Parse(dts[3]) + 65);
- sb.Append((char)int.Parse(dts[4]) + 97);
- sb.Append((char)int.Parse(dts[5]) + 97);
+ sb.Append((char) int.Parse(dts[0]) + 65);
+ sb.Append((char) int.Parse(dts[1]) + 65);
+ sb.Append((char) int.Parse(dts[2]) + 97);
+ sb.Append((char) int.Parse(dts[3]) + 65);
+ sb.Append((char) int.Parse(dts[4]) + 97);
+ sb.Append((char) int.Parse(dts[5]) + 97);
return sb.ToString();
}
diff --git a/QueryHelper.cs b/QueryHelper.cs
index 7d0dce1..5d8a1bb 100644
--- a/QueryHelper.cs
+++ b/QueryHelper.cs
@@ -1,16 +1,14 @@
// ***********************************************************************
// Assembly : FCS.Lib
// Author : FH
-// Created : 2020-07-01
+// Created : 01-01-2022
//
// Last Modified By : FH
-// Last Modified On : 2021-02-24
+// Last Modified On : 12-31-2021
// ***********************************************************************
-//
-// Copyright © FCS 2015-2022
+//
+// Copyright © 2021
//
-//
-// Implementation of https://stackoverflow.com/a/45761590
// Part of FCS.Lib - a set of utilities for C# - pieced together from fragments
// Copyright (C) 2021 FCS
//
@@ -26,7 +24,7 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-//
+
// ***********************************************************************
using System;
@@ -41,63 +39,40 @@ namespace FCS.Lib
///
public static class QueryHelper
{
- ///
- /// Orders the by.
- ///
- /// The type of the t model.
- /// The q.
- /// The name.
- /// if set to true [desc].
- /// IQueryable<TModel>.
- public static IQueryable OrderBy(this IQueryable q, string name, bool desc)
+ // https://stackoverflow.com/a/45761590
+
+ public static IQueryable OrderBy
+ (this IQueryable q, string name, bool desc)
{
var entityType = typeof(TModel);
-
var p = entityType.GetProperty(name);
-
- var m = typeof(QueryHelper).GetMethod("OrderByProperty")?.MakeGenericMethod(entityType, p.PropertyType);
-
- return (IQueryable)m.Invoke(null, new object[] { q, p, desc });
+ var m = typeof(QueryHelper)
+ .GetMethod("OrderByProperty")
+ ?.MakeGenericMethod(entityType, p.PropertyType);
+ return(IQueryable) m.Invoke(null, new object[] {
+ q, p , desc });
}
- ///
- /// Thens the by.
- ///
- /// The type of the t model.
- /// The q.
- /// The name.
- /// if set to true [desc].
- /// IQueryable<TModel>.
- public static IQueryable ThenBy(this IQueryable q, string name, bool desc)
+ public static IQueryable ThenBy
+ (this IQueryable q, string name, bool desc)
{
var entityType = typeof(TModel);
-
var p = entityType.GetProperty(name);
-
- var m = typeof(QueryHelper).GetMethod("OrderByProperty")?.MakeGenericMethod(entityType, p.PropertyType);
-
- return (IQueryable)m.Invoke(null, new object[] { q, p, desc });
+ var m = typeof(QueryHelper)
+ .GetMethod("OrderByProperty")
+ ?.MakeGenericMethod(entityType, p.PropertyType);
+ return(IQueryable) m.Invoke(null, new object[] {
+ q, p , desc });
}
- ///
- /// Orders the by property.
- ///
- /// The type of the t model.
- /// The type of the t ret.
- /// The q.
- /// The p.
- /// if set to true [desc].
- /// IQueryable<TModel>.
- public static IQueryable OrderByProperty(IQueryable q, PropertyInfo p, bool desc)
+ public static IQueryable OrderByProperty
+ (IQueryable q, PropertyInfo p, bool desc)
{
var pe = Expression.Parameter(typeof(TModel));
-
Expression se = Expression.Convert(Expression.Property(pe, p), typeof(object));
-
var exp = Expression.Lambda>(se, pe);
-
return desc ? q.OrderByDescending(exp) : q.OrderBy(exp);
}
- }
-}
\ No newline at end of file
+
+ }}
\ No newline at end of file
diff --git a/Squid.cs b/Squid.cs
index 0e50ce6..e990c1a 100644
--- a/Squid.cs
+++ b/Squid.cs
@@ -4,13 +4,16 @@
// Created : 2020-07-01
//
// Last Modified By : FH
-// Last Modified On : 2021-02-24
+// Last Modified On : 01-09-2022
// ***********************************************************************
-//
+//
// Copyright © FCS 2015-2022
//
//
-// Derived from https:github.com/csharpvitamins/CSharpVitamins.ShortGuid
+// Derived from https://www.madskristensen.net/blog/A-shorter-and-URL-friendly-GUID
+// AGPL https://www.gnu.org/licenses/agpl-3.0.en.html
+// Functional similar to https:github.com/csharpvitamins/CSharpVitamins.ShortGuid
+//
// Part of FCS.Lib - a set of utilities for C# - pieced together from fragments
// Copyright (C) 2021 FCS
//
@@ -26,7 +29,6 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-//
// ***********************************************************************
using System;
@@ -35,19 +37,15 @@ using System.Diagnostics;
namespace FCS.Lib
{
///
- /// A wrapper for handling URL-safe Base64 encoded globally unique identifiers (GUID).
+ /// A wrapper for unique identifiers (GUID).
///
- ///
- /// Special characters are replaced (/, +) or removed (==).
- /// Derived from https:github.com/csharpvitamins/CSharpVitamins.ShortGuid
- ///
+ /// Special characters are replaced (/, +) or removed (==).
[DebuggerDisplay("{" + nameof(Value) + "}")]
public readonly struct Squid : IEquatable
{
///
/// A read-only object of the Squid struct.
- /// Value is guaranteed to be all zeroes.
- /// Equivalent to Guid.Empty" />.
+ /// Equivalent to .
///
public static readonly Squid Empty = new(Guid.Empty);
@@ -117,7 +115,7 @@ namespace FCS.Lib
}
///
- /// Returns the hash code for the underlying .
+ /// Returns the hash code for the guid .
///
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
public override int GetHashCode()
@@ -129,18 +127,16 @@ namespace FCS.Lib
}
///
- /// Initialises a new object of the Squid using Guid.NewGuid()" />.
+ /// Initialises a new Squid using .
///
/// New Squid object
public static Squid NewGuid()
{
- return new Squid(Guid.NewGuid());
+ return new(Guid.NewGuid());
}
///
- /// Encode string as a new Squid encoded string.
- /// The encoding is similar to Base64 with
- /// non-URL safe characters replaced, and padding removed.
+ /// Encode string as a new Squid string.
///
/// A valid .Tostring().
/// A 22 character URL-safe Base64 string.
@@ -152,8 +148,6 @@ namespace FCS.Lib
///
/// Encode a object to Squid.
- /// The encoding is similar to Base64 with
- /// non-URL safe characters replaced, and padding removed.
///
/// A valid object.
/// A 22 character URL-safe Base64 string.
@@ -231,8 +225,7 @@ namespace FCS.Lib
}
///
- /// Tries to parse the given string value and
- /// outputs the object.
+ /// Tries to parse the given string value and output the object.
///
/// The Squid encoded string or string representation of a Guid.
/// A new object from the parsed string.
@@ -258,8 +251,7 @@ namespace FCS.Lib
}
///
- /// Tries to parse the string value and
- /// outputs the underlying object.
+ /// Tries to parse the string value and outputs the underlying object.
///
/// The Squid encoded string or string representation of a Guid.
/// A new object from the parsed string.
@@ -278,8 +270,6 @@ namespace FCS.Lib
return false;
}
- #region Operators
-
///
/// Determines if both Squid objects have the same
/// underlying value.
@@ -397,6 +387,5 @@ namespace FCS.Lib
return oGuid == Guid.Empty ? Empty : new Squid(oGuid);
}
- #endregion
}
}
\ No newline at end of file
diff --git a/StringOptions.cs b/StringOptions.cs
index 350d69e..b2e2503 100644
--- a/StringOptions.cs
+++ b/StringOptions.cs
@@ -4,9 +4,9 @@
// Created : 2020-09-09
//
// Last Modified By : FH
-// Last Modified On : 2021-02-24
+// Last Modified On : 01-09-2022
// ***********************************************************************
-//
+//
// Copyright © FCS 2015-2022
//
//
@@ -25,13 +25,14 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
+
//
// ***********************************************************************
namespace FCS.Lib
{
///
- /// Class StringOptions.
+ /// Class StringOptions.
///
public class StringOptions
{