This commit is contained in:
FH 2022-02-04 08:39:06 +01:00
parent cc1dd46cc9
commit ef688cca2e
9 changed files with 100 additions and 130 deletions

View file

@ -4,12 +4,27 @@
// Created : 27-08-2016 // Created : 27-08-2016
// //
// Last Modified By : Frede H. // Last Modified By : Frede H.
// Last Modified On : 2021-02-24 // Last Modified On : 12-31-2021
// *********************************************************************** // ***********************************************************************
// <copyright file="ExtensionsEx.cs" company="FCS"> // <copyright file="ExtensionsEx.cs" company="FCS">
// Copyright © FCS 2015-2022 // Copyright © FCS 2015-2022
// </copyright> // <summary>
// <summary></summary> // 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 <https://www.gnu.org/licenses/>.
// </summary>
// *********************************************************************** // ***********************************************************************
using System; using System;
@ -18,7 +33,7 @@ using System.Collections.Generic;
namespace FCS.Lib namespace FCS.Lib
{ {
/// <summary> /// <summary>
/// Class ExtensionsEx. /// Class ExtensionsEx.
/// </summary> /// </summary>
public static class ExtensionsEx public static class ExtensionsEx
{ {

View file

@ -4,16 +4,16 @@
// Created : 2020-07-01 // Created : 2020-07-01
// //
// Last Modified By : FH // Last Modified By : FH
// Last Modified On : 2021-02-24 // Last Modified On : 01-09-2022
// *********************************************************************** // ***********************************************************************
// <copyright file="Generators.cs" company="Frede Hundewadt"> // <copyright file="Generators.cs" company="FCS">
// Copyright © FCS 2015-2022 // Copyright © FCS 2015-2022
// </copyright> // </copyright>
// <summary>
// derived from https://sourceforge.net/projects/shorturl-dotnet
// Part of FCS.Lib - a set of utilities for C# - pieced together from fragments // Part of FCS.Lib - a set of utilities for C# - pieced together from fragments
// Copyright (C) 2021 FCS // 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 // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // 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 // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// </summary>
// *********************************************************************** // ***********************************************************************
using System; using System;
@ -37,8 +37,8 @@ using System.Security.Cryptography;
namespace FCS.Lib namespace FCS.Lib
{ {
/// <summary> /// <summary>
/// Class Generators /// Class Generators
/// <remarks>generates varioous kinds of random strings. </remarks> /// <remarks>generates varioous kinds of random strings. </remarks>
/// </summary> /// </summary>
public static class Generators public static class Generators
{ {
@ -56,7 +56,7 @@ namespace FCS.Lib
/// </summary> /// </summary>
/// <param name="length">The lengt h.</param> /// <param name="length">The lengt h.</param>
/// <returns>System.String.</returns> /// <returns>System.String.</returns>
/// <remarks>derived from https://sourceforge.net/projects/shorturl-dotnet </remarks> /// <remarks></remarks>
public static string ShortUrlGenerator(int length) public static string ShortUrlGenerator(int length)
{ {
const string charsLower = "cdfghjkmnpqrstvwxyz"; const string charsLower = "cdfghjkmnpqrstvwxyz";
@ -129,8 +129,7 @@ namespace FCS.Lib
// If we processed the last character in this group, start over. // If we processed the last character in this group, start over.
if (lastCharIdx == 0) if (lastCharIdx == 0)
{ {
charsLeftInGroup[nextGroupIdx] = charsLeftInGroup[nextGroupIdx] = charGroups[nextGroupIdx].Length;
charGroups[nextGroupIdx].Length;
} }
// There are more unprocessed characters left. // There are more unprocessed characters left.
else else
@ -297,7 +296,7 @@ namespace FCS.Lib
/// Randoms the seed. /// Randoms the seed.
/// </summary> /// </summary>
/// <returns>Random.</returns> /// <returns>Random.</returns>
/// <remarks>derived from https://sourceforge.net/projects/shorturl-dotnet/</remarks> /// <remarks>derived from https://sourceforge.net/projects/shorturl-dotnet/ </remarks>
public static Random RandomSeed() public static Random RandomSeed()
{ {
// As the default randomizer is based on the current time // As the default randomizer is based on the current time

View file

@ -4,12 +4,11 @@
// Created : 03-10-2015 // Created : 03-10-2015
// //
// Last Modified By : FH // Last Modified By : FH
// Last Modified On : 2021-03-27 // Last Modified On : 12-31-2021
// *********************************************************************** // ***********************************************************************
// <copyright file="IRepositoryAsync.cs" company="FCS"> // <copyright file="IAsyncReadonlyRepo.cs" company="FCS">
// Copyright © FCS 2015-2022 // Copyright © FCS 2015-2022
// </copyright> // </copyright>
// <summary>
// Part of FCS.Lib - a set of utilities for C# - pieced together from fragments // Part of FCS.Lib - a set of utilities for C# - pieced together from fragments
// Copyright (C) 2021 FCS // Copyright (C) 2021 FCS
// //
@ -25,7 +24,7 @@
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// </summary>
// *********************************************************************** // ***********************************************************************
using System; using System;
@ -37,7 +36,7 @@ using System.Threading.Tasks;
namespace FCS.Lib namespace FCS.Lib
{ {
/// <summary> /// <summary>
/// Interface IRepositoryAsync /// Interface IRepositoryAsync
/// </summary> /// </summary>
/// <typeparam name="TEntity">The type of the t entity.</typeparam> /// <typeparam name="TEntity">The type of the t entity.</typeparam>
public interface IAsyncReadonlyRepo<TEntity> where TEntity : class public interface IAsyncReadonlyRepo<TEntity> where TEntity : class

View file

@ -4,12 +4,11 @@
// Created : 05-13-2020 // Created : 05-13-2020
// //
// Last Modified By : FH // Last Modified By : FH
// Last Modified On : 2021-02-24 // Last Modified On : 12-31-2021
// *********************************************************************** // ***********************************************************************
// <copyright file="IRepository.cs" company="FCS"> // <copyright file="IRepository.cs" company="FCS">
// Copyright © FCS 2015-2022 // Copyright © FCS 2015-2022
// </copyright> // </copyright>
// <summary>
// Part of FCS.Lib - a set of utilities for C# - pieced together from fragments // Part of FCS.Lib - a set of utilities for C# - pieced together from fragments
// Copyright (C) 2021 FCS // Copyright (C) 2021 FCS
// //
@ -25,13 +24,13 @@
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// </summary>
// *********************************************************************** // ***********************************************************************
namespace FCS.Lib namespace FCS.Lib
{ {
/// <summary> /// <summary>
/// Interface IRepository /// Interface IRepository
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
/// <typeparam name="TKey">The type of the TKey.</typeparam> /// <typeparam name="TKey">The type of the TKey.</typeparam>

View file

@ -4,12 +4,11 @@
// Created : 03-10-2015 // Created : 03-10-2015
// //
// Last Modified By : FH // Last Modified By : FH
// Last Modified On : 2021-11-13 // Last Modified On : 12-31-2021
// *********************************************************************** // ***********************************************************************
// <copyright file="IRepositoryEx.cs" company="FCS"> // <copyright file="IRepositoryEx.cs" company="FCS">
// Copyright © FCS 2015-2022 // Copyright © FCS 2015-2022
// </copyright> // </copyright>
// <summary>
// Part of FCS.Lib - a set of utilities for C# - pieced together from fragments // Part of FCS.Lib - a set of utilities for C# - pieced together from fragments
// Copyright (C) 2021 FCS // Copyright (C) 2021 FCS
// //
@ -25,7 +24,7 @@
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// </summary>
// *********************************************************************** // ***********************************************************************
using System; using System;
@ -36,7 +35,7 @@ using System.Threading.Tasks;
namespace FCS.Lib namespace FCS.Lib
{ {
/// <summary> /// <summary>
/// Interface IRepositoryEx /// Interface IRepositoryEx
/// </summary> /// </summary>
/// <typeparam name="TEntity">The type of the t entity</typeparam> /// <typeparam name="TEntity">The type of the t entity</typeparam>
public interface IRepositoryEx<TEntity> where TEntity : class public interface IRepositoryEx<TEntity> where TEntity : class

View file

@ -4,12 +4,11 @@
// Created : 27-08-2016 // Created : 27-08-2016
// //
// Last Modified By : Frede H. // Last Modified By : Frede H.
// Last Modified On : 2021-02-24 // Last Modified On : 12-31-2021
// *********************************************************************** // ***********************************************************************
// <copyright file="Mogrifiers.cs" company="FCS"> // <copyright file="Mogrifiers.cs" company="FCS">
// Copyright © FCS 2015-2022 // Copyright © FCS 2015-2022
// </copyright> // </copyright>
// <summary>
// Part of FCS.Lib - a set of utilities for C# - pieced together from fragments // Part of FCS.Lib - a set of utilities for C# - pieced together from fragments
// Copyright (C) 2021 FCS // Copyright (C) 2021 FCS
// //
@ -25,7 +24,7 @@
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// </summary>
// *********************************************************************** // ***********************************************************************
using System; using System;
@ -40,7 +39,7 @@ using System.Text.RegularExpressions;
namespace FCS.Lib namespace FCS.Lib
{ {
/// <summary> /// <summary>
/// Class Converters /// Class Converters
/// </summary> /// </summary>
public static class Mogrifiers public static class Mogrifiers
{ {
@ -119,7 +118,7 @@ namespace FCS.Lib
/// <returns>T.</returns> /// <returns>T.</returns>
public static T IntToEnum<T>(int value) public static T IntToEnum<T>(int value)
{ {
return (T)Enum.ToObject(typeof(T), value); return (T) Enum.ToObject(typeof(T), value);
} }
/// <summary> /// <summary>
@ -171,7 +170,7 @@ namespace FCS.Lib
{ {
var empty = string.Empty; var empty = string.Empty;
if (list == null) return 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()) while (enumerator != null && enumerator.MoveNext())
if (enumerator.Current != null) if (enumerator.Current != null)
empty = string.Concat(empty, enumerator.Current.ToString(), delimiter); empty = string.Concat(empty, enumerator.Current.ToString(), delimiter);
@ -228,8 +227,8 @@ namespace FCS.Lib
return return
!decimal.TryParse(inString.Replace(",", "").Replace(".", ""), NumberStyles.Number, !decimal.TryParse(inString.Replace(",", "").Replace(".", ""), NumberStyles.Number,
CultureInfo.InvariantCulture, out var num) CultureInfo.InvariantCulture, out var num)
? null ? (decimal?) null
: decimal.Divide(num, new decimal((long)100)); : decimal.Divide(num, new decimal((long) 100));
} }
/// <summary> /// <summary>
@ -240,7 +239,7 @@ namespace FCS.Lib
/// <returns>T.</returns> /// <returns>T.</returns>
public static T StringToEnum<T>(string value) public static T StringToEnum<T>(string value)
{ {
return (T)Enum.Parse(typeof(T), value, true); return (T) Enum.Parse(typeof(T), value, true);
} }
/// <summary> /// <summary>
@ -263,11 +262,6 @@ namespace FCS.Lib
/// <returns>List&lt;T&gt;.</returns> /// <returns>List&lt;T&gt;.</returns>
/// <exception cref="ArgumentNullException">value</exception> /// <exception cref="ArgumentNullException">value</exception>
/// <exception cref="ArgumentNullException">delimiter</exception> /// <exception cref="ArgumentNullException">delimiter</exception>
/// <exception cref="ArgumentNullException">value</exception>
/// <exception cref="ArgumentNullException">delimiter</exception>
/// <exception cref="ArgumentNullException">value</exception>
/// <exception cref="ArgumentNullException">delimiter</exception>
/// <exception cref="ArgumentNullException">value</exception>
public static List<T> StringToList<T>(string value, string delimiter) public static List<T> StringToList<T>(string value, string delimiter)
{ {
if (string.IsNullOrEmpty(value)) throw new ArgumentNullException(nameof(value)); if (string.IsNullOrEmpty(value)) throw new ArgumentNullException(nameof(value));
@ -282,16 +276,16 @@ namespace FCS.Lib
var upperInvariant = o.ToUpperInvariant(); var upperInvariant = o.ToUpperInvariant();
if (string.CompareOrdinal(upperInvariant, "system.string") == 0) 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) 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) else if (string.CompareOrdinal(upperInvariant, "system.guid") == 0)
{ {
var guid = new Guid(str); 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 dt = DateTime.UtcNow.ToString("yy MM dd HH MM ss");
var sb = new StringBuilder(); var sb = new StringBuilder();
var dts = dt.Split(' '); var dts = dt.Split(' ');
sb.Append((char)int.Parse(dts[0]) + 65); sb.Append((char) int.Parse(dts[0]) + 65);
sb.Append((char)int.Parse(dts[1]) + 65); sb.Append((char) int.Parse(dts[1]) + 65);
sb.Append((char)int.Parse(dts[2]) + 97); sb.Append((char) int.Parse(dts[2]) + 97);
sb.Append((char)int.Parse(dts[3]) + 65); sb.Append((char) int.Parse(dts[3]) + 65);
sb.Append((char)int.Parse(dts[4]) + 97); sb.Append((char) int.Parse(dts[4]) + 97);
sb.Append((char)int.Parse(dts[5]) + 97); sb.Append((char) int.Parse(dts[5]) + 97);
return sb.ToString(); return sb.ToString();
} }

View file

@ -1,16 +1,14 @@
// *********************************************************************** // ***********************************************************************
// Assembly : FCS.Lib // Assembly : FCS.Lib
// Author : FH // Author : FH
// Created : 2020-07-01 // Created : 01-01-2022
// //
// Last Modified By : FH // Last Modified By : FH
// Last Modified On : 2021-02-24 // Last Modified On : 12-31-2021
// *********************************************************************** // ***********************************************************************
// <copyright file="QueryHelper.cs" company="Frede Hundewadt"> // <copyright file="QueryHelper.cs" company="">
// Copyright © FCS 2015-2022 // Copyright © 2021
// </copyright> // </copyright>
// <summary>
// Implementation of https://stackoverflow.com/a/45761590
// Part of FCS.Lib - a set of utilities for C# - pieced together from fragments // Part of FCS.Lib - a set of utilities for C# - pieced together from fragments
// Copyright (C) 2021 FCS // Copyright (C) 2021 FCS
// //
@ -26,7 +24,7 @@
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// </summary>
// *********************************************************************** // ***********************************************************************
using System; using System;
@ -41,63 +39,40 @@ namespace FCS.Lib
/// </summary> /// </summary>
public static class QueryHelper public static class QueryHelper
{ {
/// <summary> // https://stackoverflow.com/a/45761590
/// Orders the by.
/// </summary> public static IQueryable<TModel> OrderBy<TModel>
/// <typeparam name="TModel">The type of the t model.</typeparam> (this IQueryable<TModel> q, string name, bool desc)
/// <param name="q">The q.</param>
/// <param name="name">The name.</param>
/// <param name="desc">if set to <c>true</c> [desc].</param>
/// <returns>IQueryable&lt;TModel&gt;.</returns>
public static IQueryable<TModel> OrderBy<TModel>(this IQueryable<TModel> q, string name, bool desc)
{ {
var entityType = typeof(TModel); var entityType = typeof(TModel);
var p = entityType.GetProperty(name); var p = entityType.GetProperty(name);
var m = typeof(QueryHelper)
var m = typeof(QueryHelper).GetMethod("OrderByProperty")?.MakeGenericMethod(entityType, p.PropertyType); .GetMethod("OrderByProperty")
?.MakeGenericMethod(entityType, p.PropertyType);
return (IQueryable<TModel>)m.Invoke(null, new object[] { q, p, desc }); return(IQueryable<TModel>) m.Invoke(null, new object[] {
q, p , desc });
} }
/// <summary> public static IQueryable<TModel> ThenBy<TModel>
/// Thens the by. (this IQueryable<TModel> q, string name, bool desc)
/// </summary>
/// <typeparam name="TModel">The type of the t model.</typeparam>
/// <param name="q">The q.</param>
/// <param name="name">The name.</param>
/// <param name="desc">if set to <c>true</c> [desc].</param>
/// <returns>IQueryable&lt;TModel&gt;.</returns>
public static IQueryable<TModel> ThenBy<TModel>(this IQueryable<TModel> q, string name, bool desc)
{ {
var entityType = typeof(TModel); var entityType = typeof(TModel);
var p = entityType.GetProperty(name); var p = entityType.GetProperty(name);
var m = typeof(QueryHelper)
var m = typeof(QueryHelper).GetMethod("OrderByProperty")?.MakeGenericMethod(entityType, p.PropertyType); .GetMethod("OrderByProperty")
?.MakeGenericMethod(entityType, p.PropertyType);
return (IQueryable<TModel>)m.Invoke(null, new object[] { q, p, desc }); return(IQueryable<TModel>) m.Invoke(null, new object[] {
q, p , desc });
} }
/// <summary> public static IQueryable<TModel> OrderByProperty<TModel, TRet>
/// Orders the by property. (IQueryable<TModel> q, PropertyInfo p, bool desc)
/// </summary>
/// <typeparam name="TModel">The type of the t model.</typeparam>
/// <typeparam name="TRet">The type of the t ret.</typeparam>
/// <param name="q">The q.</param>
/// <param name="p">The p.</param>
/// <param name="desc">if set to <c>true</c> [desc].</param>
/// <returns>IQueryable&lt;TModel&gt;.</returns>
public static IQueryable<TModel> OrderByProperty<TModel, TRet>(IQueryable<TModel> q, PropertyInfo p, bool desc)
{ {
var pe = Expression.Parameter(typeof(TModel)); var pe = Expression.Parameter(typeof(TModel));
Expression se = Expression.Convert(Expression.Property(pe, p), typeof(object)); Expression se = Expression.Convert(Expression.Property(pe, p), typeof(object));
var exp = Expression.Lambda<Func<TModel, TRet>>(se, pe); var exp = Expression.Lambda<Func<TModel, TRet>>(se, pe);
return desc ? q.OrderByDescending(exp) : q.OrderBy(exp); return desc ? q.OrderByDescending(exp) : q.OrderBy(exp);
} }
}
} }}

View file

@ -4,13 +4,16 @@
// Created : 2020-07-01 // Created : 2020-07-01
// //
// Last Modified By : FH // Last Modified By : FH
// Last Modified On : 2021-02-24 // Last Modified On : 01-09-2022
// *********************************************************************** // ***********************************************************************
// <copyright file="Squid.cs" company="Frede Hundewadt"> // <copyright file="Squid.cs" company="FCS">
// Copyright © FCS 2015-2022 // Copyright © FCS 2015-2022
// </copyright> // </copyright>
// <summary> // <summary>
// 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 // Part of FCS.Lib - a set of utilities for C# - pieced together from fragments
// Copyright (C) 2021 FCS // Copyright (C) 2021 FCS
// //
@ -26,7 +29,6 @@
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// </summary>
// *********************************************************************** // ***********************************************************************
using System; using System;
@ -35,19 +37,15 @@ using System.Diagnostics;
namespace FCS.Lib namespace FCS.Lib
{ {
/// <summary> /// <summary>
/// A wrapper for handling URL-safe Base64 encoded globally unique identifiers (GUID). /// A wrapper for unique identifiers (GUID).
/// </summary> /// </summary>
/// <remarks> /// <remarks>Special characters are replaced (/, +) or removed (==).</remarks>
/// Special characters are replaced (/, +) or removed (==).
/// Derived from https:github.com/csharpvitamins/CSharpVitamins.ShortGuid
/// </remarks>
[DebuggerDisplay("{" + nameof(Value) + "}")] [DebuggerDisplay("{" + nameof(Value) + "}")]
public readonly struct Squid : IEquatable<Squid> public readonly struct Squid : IEquatable<Squid>
{ {
/// <summary> /// <summary>
/// A read-only object of the Squid struct. /// A read-only object of the Squid struct.
/// Value is guaranteed to be all zeroes. /// Equivalent to <see cref="Guid.Empty" />.
/// Equivalent to Guid.Empty" />.
/// </summary> /// </summary>
public static readonly Squid Empty = new(Guid.Empty); public static readonly Squid Empty = new(Guid.Empty);
@ -117,7 +115,7 @@ namespace FCS.Lib
} }
/// <summary> /// <summary>
/// Returns the hash code for the underlying <see cref="System.Guid" />. /// Returns the hash code for the guid <see cref="System.Guid" />.
/// </summary> /// </summary>
/// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns> /// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns>
public override int GetHashCode() public override int GetHashCode()
@ -129,18 +127,16 @@ namespace FCS.Lib
} }
/// <summary> /// <summary>
/// Initialises a new object of the Squid using Guid.NewGuid()" />. /// Initialises a new Squid using <see cref="Guid.NewGuid()" />.
/// </summary> /// </summary>
/// <returns>New Squid object</returns> /// <returns>New Squid object</returns>
public static Squid NewGuid() public static Squid NewGuid()
{ {
return new Squid(Guid.NewGuid()); return new(Guid.NewGuid());
} }
/// <summary> /// <summary>
/// Encode string as a new Squid encoded string. /// Encode string as a new Squid string.
/// The encoding is similar to Base64 with
/// non-URL safe characters replaced, and padding removed.
/// </summary> /// </summary>
/// <param name="value">A valid <see cref="System.Guid" />.Tostring().</param> /// <param name="value">A valid <see cref="System.Guid" />.Tostring().</param>
/// <returns>A 22 character URL-safe Base64 string.</returns> /// <returns>A 22 character URL-safe Base64 string.</returns>
@ -152,8 +148,6 @@ namespace FCS.Lib
/// <summary> /// <summary>
/// Encode a <see cref="System.Guid" /> object to Squid. /// Encode a <see cref="System.Guid" /> object to Squid.
/// The encoding is similar to Base64 with
/// non-URL safe characters replaced, and padding removed.
/// </summary> /// </summary>
/// <param name="obj">A valid <see cref="System.Guid" /> object.</param> /// <param name="obj">A valid <see cref="System.Guid" /> object.</param>
/// <returns>A 22 character URL-safe Base64 string.</returns> /// <returns>A 22 character URL-safe Base64 string.</returns>
@ -231,8 +225,7 @@ namespace FCS.Lib
} }
/// <summary> /// <summary>
/// Tries to parse the given string value and /// Tries to parse the given string value and output the <see cref="Squid" /> object.
/// outputs the <see cref="Squid" /> object.
/// </summary> /// </summary>
/// <param name="value">The Squid encoded string or string representation of a Guid.</param> /// <param name="value">The Squid encoded string or string representation of a Guid.</param>
/// <param name="obj">A new <see cref="Squid" /> object from the parsed string.</param> /// <param name="obj">A new <see cref="Squid" /> object from the parsed string.</param>
@ -258,8 +251,7 @@ namespace FCS.Lib
} }
/// <summary> /// <summary>
/// Tries to parse the string value and /// Tries to parse the string value and outputs the underlying <see cref="System.Guid" /> object.
/// outputs the underlying <see cref="System.Guid" /> object.
/// </summary> /// </summary>
/// <param name="value">The Squid encoded string or string representation of a Guid.</param> /// <param name="value">The Squid encoded string or string representation of a Guid.</param>
/// <param name="obj">A new <see cref="System.Guid" /> object from the parsed string.</param> /// <param name="obj">A new <see cref="System.Guid" /> object from the parsed string.</param>
@ -278,8 +270,6 @@ namespace FCS.Lib
return false; return false;
} }
#region Operators
/// <summary> /// <summary>
/// Determines if both Squid objects have the same /// Determines if both Squid objects have the same
/// underlying <see cref="System.Guid" /> value. /// underlying <see cref="System.Guid" /> value.
@ -397,6 +387,5 @@ namespace FCS.Lib
return oGuid == Guid.Empty ? Empty : new Squid(oGuid); return oGuid == Guid.Empty ? Empty : new Squid(oGuid);
} }
#endregion
} }
} }

View file

@ -4,9 +4,9 @@
// Created : 2020-09-09 // Created : 2020-09-09
// //
// Last Modified By : FH // Last Modified By : FH
// Last Modified On : 2021-02-24 // Last Modified On : 01-09-2022
// *********************************************************************** // ***********************************************************************
// <copyright file="StringOptions.cs" company="Frede Hundewadt"> // <copyright file="StringOptions.cs" company="FCS">
// Copyright © FCS 2015-2022 // Copyright © FCS 2015-2022
// </copyright> // </copyright>
// <summary> // <summary>
@ -25,13 +25,14 @@
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// </summary> // </summary>
// *********************************************************************** // ***********************************************************************
namespace FCS.Lib namespace FCS.Lib
{ {
/// <summary> /// <summary>
/// Class StringOptions. /// Class StringOptions.
/// </summary> /// </summary>
public class StringOptions public class StringOptions
{ {