update headers

This commit is contained in:
Frede Hundewadt 2023-03-21 07:19:55 +01:00
parent d8f5895dbb
commit 477a3a2e2b
13 changed files with 2151 additions and 2096 deletions

View file

@ -1,25 +1,25 @@
// ***********************************************************************
// Assembly : FCS.Lib.Utility
// Author : FH
// Created : 27-08-2016
// Author : fhdk
// Created : 2022 12 17 13:33
//
// Last Modified By : Frede H.
// Last Modified On : 02-24-2022
// Last Modified By: fhdk
// Last Modified On : 2023 03 14 09:16
// ***********************************************************************
// <copyright file="ExtensionsEx.cs" company="FCS-TECH">
// Copyright (C) 2022 FCS Frede's Computer Services.
// <copyright file="ExtensionsEx.cs" company="FCS">
// Copyright (C) 2022-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the Affero GNU 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
// 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
// Affero GNU General Public License for more details.
// GNU Affero General Public License for more details.
//
// You should have received a copy of the Affero GNU General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
// 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]
// </copyright>
// <summary></summary>
// ***********************************************************************
@ -27,13 +27,13 @@
using System;
using System.Collections.Generic;
namespace FCS.Lib.Utility
namespace FCS.Lib.Utility;
/// <summary>
/// Class ExtensionsEx.
/// </summary>
public static class ExtensionsEx
{
/// <summary>
/// Class ExtensionsEx.
/// </summary>
public static class ExtensionsEx
{
/// <summary>
/// ForEach loop
/// </summary>
@ -45,5 +45,4 @@ namespace FCS.Lib.Utility
foreach (var item in items)
action(item);
}
}
}

View file

@ -1,25 +1,25 @@
// ***********************************************************************
// Assembly : FCS.Lib.Utility
// Author : FH
// Created : 2020-07-01
// Author : fhdk
// Created : 2023 02 02 06:59
//
// Last Modified By : FH
// Last Modified On : 02-24-2022
// Last Modified By: fhdk
// Last Modified On : 2023 03 14 09:16
// ***********************************************************************
// <copyright file="Generators.cs" company="FCS-TECH">
// Copyright (C) 2022 FCS Frede's Computer Services.
// <copyright file="Generators.cs" company="FCS">
// Copyright (C) 2023-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the Affero GNU 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
// 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
// Affero GNU General Public License for more details.
// GNU Affero General Public License for more details.
//
// You should have received a copy of the Affero GNU General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
// 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]
// </copyright>
// <summary></summary>
// ***********************************************************************
@ -29,13 +29,13 @@ using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
namespace FCS.Lib.Utility
namespace FCS.Lib.Utility;
/// <summary>
/// Generators
/// </summary>
public static class Generators
{
/// <summary>
/// Generators
/// </summary>
public static class Generators
{
/// <summary>
/// Generate 6 character shortUrl
/// </summary>
@ -81,7 +81,7 @@ namespace FCS.Lib.Utility
for (var i = 0; i < leftGroupsOrder.Length; i++)
leftGroupsOrder[i] = i;
// Using our private randomizer
// Using our private random number generator
var random = RandomSeed();
// This array will hold short-url characters.
@ -133,9 +133,8 @@ namespace FCS.Lib.Utility
// so that we don't pick it until we process all characters in
// this group.
if (lastCharIdx != nextCharIdx)
{
(charGroups[nextGroupIdx][lastCharIdx], charGroups[nextGroupIdx][nextCharIdx]) = (charGroups[nextGroupIdx][nextCharIdx], charGroups[nextGroupIdx][lastCharIdx]);
}
(charGroups[nextGroupIdx][lastCharIdx], charGroups[nextGroupIdx][nextCharIdx]) = (
charGroups[nextGroupIdx][nextCharIdx], charGroups[nextGroupIdx][lastCharIdx]);
// Decrement the number of unprocessed characters in
// this group.
@ -153,9 +152,8 @@ namespace FCS.Lib.Utility
// Swap processed group with the last unprocessed group
// so that we don't pick it until we process all groups.
if (lastLeftGroupsOrderIdx != nextLeftGroupsOrderIdx)
{
(leftGroupsOrder[lastLeftGroupsOrderIdx], leftGroupsOrder[nextLeftGroupsOrderIdx]) = (leftGroupsOrder[nextLeftGroupsOrderIdx], leftGroupsOrder[lastLeftGroupsOrderIdx]);
}
(leftGroupsOrder[lastLeftGroupsOrderIdx], leftGroupsOrder[nextLeftGroupsOrderIdx]) = (
leftGroupsOrder[nextLeftGroupsOrderIdx], leftGroupsOrder[lastLeftGroupsOrderIdx]);
// Decrement the number of unprocessed groups.
lastLeftGroupsOrderIdx--;
@ -176,7 +174,7 @@ namespace FCS.Lib.Utility
{
options ??= new StringOptions
{
RequiredLength = 10,
RequiredLength = 16,
RequireDigit = true,
RequireLowercase = true,
RequireUppercase = true,
@ -197,13 +195,13 @@ namespace FCS.Lib.Utility
{
options ??= new StringOptions
{
RequiredLength = 10,
RequiredLength = 16,
RequireDigit = true,
RequireLowercase = true,
RequireUppercase = true,
RequiredUniqueChars = 4,
RequireNonLetterOrDigit = true,
RequireNonAlphanumeric = true
RequiredUniqueChars = 8,
RequireNonLetterOrDigit = false,
RequireNonAlphanumeric = false
};
return GenerateRandomString(options);
}
@ -240,7 +238,7 @@ namespace FCS.Lib.Utility
{
options ??= new StringOptions
{
RequiredLength = 10,
RequiredLength = 16,
RequireDigit = true,
RequireLowercase = true,
RequireUppercase = true,
@ -257,7 +255,7 @@ namespace FCS.Lib.Utility
"!@$?_-" // non-alphanumeric
};
// Using our private randomizer
// Using our private random number generator
var rand = RandomSeed();
var chars = new List<char>();
@ -319,5 +317,4 @@ namespace FCS.Lib.Utility
// Return a truly randomized random generator
return new Random(seed);
}
}
}

View file

@ -1,15 +1,40 @@
using System;
// ***********************************************************************
// Assembly : FCS.Lib.Utility
// Author : fhdk
// Created : 2022 12 17 13:33
//
// Last Modified By: fhdk
// Last Modified On : 2023 03 14 09:16
// ***********************************************************************
// <copyright file="GuidGenerator.cs" company="FCS">
// Copyright (C) 2022-2023 FCS Frede's Computer Services.
// 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]
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.Text;
namespace FCS.Lib.Utility
{
/// <summary>
/// Used for generating UUID based on RFC 4122.
/// </summary>
/// <seealso href="http://www.ietf.org/rfc/rfc4122.txt">RFC 4122 - A Universally Unique IDentifier (UUID) URN Namespace</seealso>
public static class GuidGenerator
{
namespace FCS.Lib.Utility;
/// <summary>
/// Used for generating UUID based on RFC 4122.
/// </summary>
/// <seealso href="http://www.ietf.org/rfc/rfc4122.txt">RFC 4122 - A Universally Unique IDentifier (UUID) URN Namespace</seealso>
public static class GuidGenerator
{
/// <summary>
/// number of bytes in guid
/// </summary>
@ -53,16 +78,6 @@ namespace FCS.Lib.Utility
// offset to move from 1/1/0001, which is 0-time for .NET, to gregorian 0-time of 10/15/1582
private static readonly DateTimeOffset GregorianCalendarStart = new(1582, 10, 15, 0, 0, 0, TimeSpan.Zero);
/// <summary>
/// Default clock sequence
/// </summary>
public static byte[] DefaultClockSequence { get; set; }
/// <summary>
/// Default node
/// </summary>
public static byte[] DefaultNode { get; set; }
static GuidGenerator()
{
DefaultClockSequence = new byte[2];
@ -73,6 +88,17 @@ namespace FCS.Lib.Utility
random.NextBytes(DefaultNode);
}
/// <summary>
/// Default clock sequence
/// </summary>
public static byte[] DefaultClockSequence { get; set; }
/// <summary>
/// Default node
/// </summary>
public static byte[] DefaultNode { get; set; }
/// <summary>
/// Set default node
/// </summary>
@ -247,5 +273,4 @@ namespace FCS.Lib.Utility
return new Guid(guid);
}
}
}

View file

@ -1,25 +1,53 @@
namespace FCS.Lib.Utility
// ***********************************************************************
// Assembly : FCS.Lib.Utility
// Author : fhdk
// Created : 2022 12 17 13:33
//
// Last Modified By: fhdk
// Last Modified On : 2023 03 14 09:16
// ***********************************************************************
// <copyright file="GuidVersion.cs" company="FCS">
// Copyright (C) 2022-2023 FCS Frede's Computer Services.
// 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]
// </copyright>
// <summary></summary>
// ***********************************************************************
namespace FCS.Lib.Utility;
/// <summary>
/// Guid Version Enum
/// </summary>
public enum GuidVersion
{
/// <summary>
/// Guid Version Enum
/// </summary>
public enum GuidVersion
{
/// <summary>
/// Time
/// </summary>
TimeBased = 0x01,
/// <summary>
/// Reserved
/// </summary>
Reserved = 0x02,
/// <summary>
/// Name
/// </summary>
NameBased = 0x03,
/// <summary>
/// Random
/// </summary>
Random = 0x04
}
}

View file

@ -1,25 +1,25 @@
// ***********************************************************************
// Assembly : FCS.Lib.Utility
// Author : FH
// Created : 03-10-2015
// Author : fhdk
// Created : 2023 01 23 07:31
//
// Last Modified By : FH
// Last Modified On : 02-24-2022
// Last Modified By: fhdk
// Last Modified On : 2023 03 14 09:16
// ***********************************************************************
// <copyright file="IAsyncReadonlyRepo.cs" company="FCS-TECH">
// Copyright (C) 2022 FCS Frede's Computer Services.
// <copyright file="IAsyncReadonlyRepo.cs" company="FCS">
// Copyright (C) 2023-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the Affero GNU 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
// 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
// Affero GNU General Public License for more details.
// GNU Affero General Public License for more details.
//
// You should have received a copy of the Affero GNU General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
// 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]
// </copyright>
// <summary></summary>
// ***********************************************************************
@ -30,14 +30,14 @@ using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace FCS.Lib.Utility
namespace FCS.Lib.Utility;
/// <summary>
/// Interface IRepositoryAsync
/// </summary>
/// <typeparam name="TEntity">The type of the t entity.</typeparam>
public interface IAsyncReadonlyRepo<TEntity> where TEntity : class
{
/// <summary>
/// Interface IRepositoryAsync
/// </summary>
/// <typeparam name="TEntity">The type of the t entity.</typeparam>
public interface IAsyncReadonlyRepo<TEntity> where TEntity : class
{
/// <summary>
/// Queryable
/// </summary>
@ -92,5 +92,4 @@ namespace FCS.Lib.Utility
/// <param name="id">The identifier.</param>
/// <returns>TEntity.</returns>
TEntity GetById(string id);
}
}

View file

@ -1,38 +1,38 @@
// ***********************************************************************
// Assembly : FCS.Lib.Utility
// Author : FH
// Created : 05-13-2020
// Author : fhdk
// Created : 2022 12 17 13:33
//
// Last Modified By : FH
// Last Modified On : 02-24-2022
// Last Modified By: fhdk
// Last Modified On : 2023 03 14 09:16
// ***********************************************************************
// <copyright file="IRepository.cs" company="FCS-TECH">
// Copyright (C) 2022 FCS Frede's Computer Services.
// <copyright file="IRepository.cs" company="FCS">
// Copyright (C) 2022-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the Affero GNU 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
// 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
// Affero GNU General Public License for more details.
// GNU Affero General Public License for more details.
//
// You should have received a copy of the Affero GNU General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
// 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]
// </copyright>
// <summary></summary>
// ***********************************************************************
namespace FCS.Lib.Utility
namespace FCS.Lib.Utility;
/// <summary>
/// Interface IRepository
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="TKey">The type of the TKey.</typeparam>
public interface IRepository<T, in TKey> where T : class
{
/// <summary>
/// Interface IRepository
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="TKey">The type of the TKey.</typeparam>
public interface IRepository<T, in TKey> where T : class
{
/// <summary>
/// Gets the specified identifier.
/// </summary>
@ -57,5 +57,4 @@ namespace FCS.Lib.Utility
/// </summary>
/// <param name="id">The identifier.</param>
void Delete(TKey id);
}
}

View file

@ -1,25 +1,25 @@
// ***********************************************************************
// Assembly : FCS.Lib.Utility
// Author : FH
// Created : 03-10-2015
// Author : fhdk
// Created : 2022 12 17 13:33
//
// Last Modified By : FH
// Last Modified On : 02-24-2022
// Last Modified By: fhdk
// Last Modified On : 2023 03 14 09:16
// ***********************************************************************
// <copyright file="IRepositoryEx.cs" company="FCS-TECH">
// Copyright (C) 2022 FCS Frede's Computer Services.
// <copyright file="IRepositoryEx.cs" company="FCS">
// Copyright (C) 2022-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the Affero GNU 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
// 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
// Affero GNU General Public License for more details.
// GNU Affero General Public License for more details.
//
// You should have received a copy of the Affero GNU General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
// 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]
// </copyright>
// <summary></summary>
// ***********************************************************************
@ -29,14 +29,14 @@ using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace FCS.Lib.Utility
namespace FCS.Lib.Utility;
/// <summary>
/// Interface IRepositoryEx
/// </summary>
/// <typeparam name="TEntity">The type of the t entity</typeparam>
public interface IRepositoryEx<TEntity> where TEntity : class
{
/// <summary>
/// Interface IRepositoryEx
/// </summary>
/// <typeparam name="TEntity">The type of the t entity</typeparam>
public interface IRepositoryEx<TEntity> where TEntity : class
{
/// <summary>
/// Get all entities synchronous
/// </summary>
@ -123,5 +123,4 @@ namespace FCS.Lib.Utility
/// </summary>
/// <returns>IQueryable&lt;TEntity&gt;</returns>
IQueryable<TEntity> All();
}
}

View file

@ -1,25 +1,25 @@
// ***********************************************************************
// Assembly : FCS.Lib.Utility
// Author : FH
// Created : 27-08-2016
// Author : fhdk
// Created : 2023 03 02 09:52
//
// Last Modified By : Frede H.
// Last Modified On : 02-24-2022
// Last Modified By: fhdk
// Last Modified On : 2023 03 14 09:16
// ***********************************************************************
// <copyright file="Mogrify.cs" company="FCS-TECH">
// Copyright (C) 2022 FCS Frede's Computer Services.
// <copyright file="Mogrify.cs" company="FCS">
// Copyright (C) 2023-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the Affero GNU 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
// 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
// Affero GNU General Public License for more details.
// GNU Affero General Public License for more details.
//
// You should have received a copy of the Affero GNU General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
// 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]
// </copyright>
// <summary></summary>
// ***********************************************************************
@ -33,13 +33,27 @@ using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace FCS.Lib.Utility
namespace FCS.Lib.Utility;
/// <summary>
/// Mogrify between units
/// </summary>
public static class Mogrify
{
/// <summary>
/// Mogrify between units
/// Remove everything but digits and country code
/// </summary>
public static class Mogrify
/// <param name="phone"></param>
/// <returns></returns>
public static string SanitizePhone(string phone)
{
if (string.IsNullOrWhiteSpace(phone))
return "";
phone = phone.Replace("+45", "").Replace("+46", "").Replace("+47", "");
var regexObj = new Regex(@"[^\d]");
return regexObj.Replace(phone, "");
}
/// <summary>
/// Get month from timestamp
/// </summary>
@ -70,6 +84,7 @@ namespace FCS.Lib.Utility
{
return DateTimeIso8601(TimeStampToDateTime(timestamp));
}
/// <summary>
/// return date as ISO
/// </summary>
@ -77,7 +92,7 @@ namespace FCS.Lib.Utility
/// <returns></returns>
public static string DateTimeIso8601(DateTime date)
{
return date.ToString("o",CultureInfo.InvariantCulture);
return date.ToString("o", CultureInfo.InvariantCulture);
}
/// <summary>
@ -85,11 +100,12 @@ namespace FCS.Lib.Utility
/// </summary>
/// <param name="dateTime"></param>
/// <returns>dictionary</returns>
public static Dictionary<string,long> DateToTimestampRange(DateTime dateTime)
public static Dictionary<string, long> DateToTimestampRange(DateTime dateTime)
{
var dt1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day,0,0,0);
var dt1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, 0, 0, 0);
var dt2 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, 23, 59, 59);
return new Dictionary<string, long>{
return new Dictionary<string, long>
{
{ "lower", DateTimeToTimeStamp(dt1) },
{ "upper", DateTimeToTimeStamp(dt2) }
};
@ -264,7 +280,7 @@ namespace FCS.Lib.Utility
/// <returns></returns>
public static T IntToEnum<T>(int value)
{
return (T) Enum.ToObject(typeof(T), value);
return (T)Enum.ToObject(typeof(T), value);
}
/// <summary>
@ -289,7 +305,7 @@ namespace FCS.Lib.Utility
{
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);
@ -334,6 +350,7 @@ namespace FCS.Lib.Utility
return flag;
}
/// <summary>
/// get decimal from string
/// </summary>
@ -345,8 +362,8 @@ namespace FCS.Lib.Utility
return
!decimal.TryParse(inString.Replace(",", "").Replace(".", ""), NumberStyles.Number,
CultureInfo.InvariantCulture, out var num)
? (decimal?) null
: decimal.Divide(num, new decimal((long) 100));
? null
: decimal.Divide(num, new decimal((long)100));
}
/// <summary>
@ -393,16 +410,16 @@ namespace FCS.Lib.Utility
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));
}
}
@ -474,5 +491,4 @@ namespace FCS.Lib.Utility
// }
// return empty;
//}
}
}

View file

@ -17,5 +17,5 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
[assembly: Guid("8D850197-78DB-4D16-A91F-E5BB6E8880A7")]
[assembly: AssemblyVersion("1.0.23023.0820")]
[assembly: AssemblyFileVersion("1.0.23023.0820")]
[assembly: AssemblyVersion("1.0.23077.1334")]
[assembly: AssemblyFileVersion("1.0.23077.1334")]

View file

@ -1,25 +1,25 @@
// ***********************************************************************
// Assembly : FCS.Lib.Utility
// Author : FH
// Created : 01-01-2022
// Author : fhdk
// Created : 2022 12 17 13:33
//
// Last Modified By : FH
// Last Modified On : 02-24-2022
// Last Modified By: fhdk
// Last Modified On : 2023 03 14 09:16
// ***********************************************************************
// <copyright file="QueryHelper.cs" company="Frede Hundewadt">
// Copyright (C) 2022 FCS Frede's Computer Services.
// <copyright file="QueryHelper.cs" company="FCS">
// Copyright (C) 2022-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the Affero GNU 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
// 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
// Affero GNU General Public License for more details.
// GNU Affero General Public License for more details.
//
// You should have received a copy of the Affero GNU General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
// 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]
// </copyright>
// <summary></summary>
// ***********************************************************************
@ -29,13 +29,13 @@ using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
namespace FCS.Lib.Utility
namespace FCS.Lib.Utility;
/// <summary>
/// Class QueryHelper.
/// </summary>
public static class QueryHelper
{
/// <summary>
/// Class QueryHelper.
/// </summary>
public static class QueryHelper
{
// https://stackoverflow.com/a/45761590
/// <summary>
@ -46,7 +46,7 @@ namespace FCS.Lib.Utility
/// <param name="desc"></param>
/// <typeparam name="TModel"></typeparam>
/// <returns></returns>
public static IQueryable<TModel> OrderBy<TModel> (this IQueryable<TModel> q, string name, bool desc)
public static IQueryable<TModel> OrderBy<TModel>(this IQueryable<TModel> q, string name, bool desc)
{
var entityType = typeof(TModel);
var p = entityType.GetProperty(name);
@ -54,7 +54,7 @@ namespace FCS.Lib.Utility
.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>
@ -65,7 +65,7 @@ namespace FCS.Lib.Utility
/// <param name="desc"></param>
/// <typeparam name="TModel"></typeparam>
/// <returns></returns>
public static IQueryable<TModel> ThenBy<TModel> (this IQueryable<TModel> q, string name, bool desc)
public static IQueryable<TModel> ThenBy<TModel>(this IQueryable<TModel> q, string name, bool desc)
{
var entityType = typeof(TModel);
var p = entityType.GetProperty(name);
@ -73,7 +73,7 @@ namespace FCS.Lib.Utility
.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 });
}
@ -94,5 +94,4 @@ namespace FCS.Lib.Utility
return desc ? q.OrderByDescending(exp) : q.OrderBy(exp);
}
}}
}

View file

@ -1,42 +1,42 @@
// ***********************************************************************
// Assembly : FCS.Lib.Utility
// Author : FH
// Created : 2020-07-01
// Author : fhdk
// Created : 2022 12 17 13:33
//
// Last Modified By : FH
// Last Modified On : 02-24-2022
// Last Modified By: fhdk
// Last Modified On : 2023 03 14 09:16
// ***********************************************************************
// <copyright file="Squid.cs" company="FCS-TECH">
// Copyright (C) 2022 FCS Frede's Computer Services.
// <copyright file="Squid.cs" company="FCS">
// Copyright (C) 2022-2023 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the Affero GNU 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
// 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
// Affero GNU General Public License for more details.
// GNU Affero General Public License for more details.
//
// You should have received a copy of the Affero GNU General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
// 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]
// </copyright>
// <summary>Derived from https:github.com/csharpvitamins/CSharpVitamins.ShortGuid</summary>
// <summary></summary>
// ***********************************************************************
using System;
using System.Diagnostics;
namespace FCS.Lib.Utility
namespace FCS.Lib.Utility;
/// <summary>
/// A wrapper for handling URL-safe Base64 encoded globally unique identifiers (GUID).
/// </summary>
/// <remarks>Special characters are replaced (/, +) or removed (==).
/// Derived from https:github.com/csharpvitamins/CSharpVitamins.ShortGuid</remarks>
[DebuggerDisplay("{" + nameof(Value) + "}")]
public readonly struct Squid : IEquatable<Squid>
{
/// <summary>
/// A wrapper for handling URL-safe Base64 encoded globally unique identifiers (GUID).
/// </summary>
/// <remarks>Special characters are replaced (/, +) or removed (==).
/// Derived from https:github.com/csharpvitamins/CSharpVitamins.ShortGuid</remarks>
[DebuggerDisplay("{" + nameof(Value) + "}")]
public readonly struct Squid : IEquatable<Squid>
{
/// <summary>
/// A read-only object of the Squid struct.
/// Value is guaranteed to be all zeroes.
@ -127,7 +127,7 @@ namespace FCS.Lib.Utility
/// <returns>New Squid object</returns>
public static Squid NewGuid()
{
return new(Guid.NewGuid());
return new Squid(Guid.NewGuid());
}
/// <summary>
@ -391,5 +391,4 @@ namespace FCS.Lib.Utility
}
#endregion
}
}

View file

@ -1,13 +1,13 @@
// ***********************************************************************
// Assembly : FCS.Lib.Utility
// Author : FH
// Created : 2020-09-09
// Author : fhdk
// Created : 2022 12 17 13:33
//
// Last Modified By : FH
// Last Modified On : 03-14-2022
// Last Modified By: fhdk
// Last Modified On : 2023 03 14 09:16
// ***********************************************************************
// <copyright file="StringOptions.cs" company="FCS-TECH">
// Copyright (C) 2022 FCS Frede's Computer Services.
// <copyright file="StringOptions.cs" company="FCS">
// Copyright (C) 2022-2023 FCS Frede's Computer Services.
// 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
@ -24,13 +24,13 @@
// <summary></summary>
// ***********************************************************************
namespace FCS.Lib.Utility
namespace FCS.Lib.Utility;
/// <summary>
/// Class StringOptions.
/// </summary>
public class StringOptions
{
/// <summary>
/// Class StringOptions.
/// </summary>
public class StringOptions
{
/// <summary>
/// Gets or sets the required length of a string
/// </summary>
@ -72,5 +72,4 @@ namespace FCS.Lib.Utility
/// </summary>
/// <value><c>true</c> if [require non alphanumeric]; otherwise, <c>false</c>.</value>
public bool RequireNonAlphanumeric { get; set; }
}
}

View file

@ -1,13 +1,13 @@
// ***********************************************************************
// Assembly : FCS.Lib.Utility
// Author : FH
// Created : 03-30-2022
// Author : fhdk
// Created : 2023 03 09 17:42
//
// Last Modified By : FH
// Last Modified On : 04-19-2022
// Last Modified By: fhdk
// Last Modified On : 2023 03 14 09:16
// ***********************************************************************
// <copyright file="VatFormatValidator.cs" company="FCS-TECH">
// Copyright (C) 2022 FCS Frede's Computer Services.
// <copyright file="VatFormatValidator.cs" company="FCS">
// Copyright (C) 2023-2023 FCS Frede's Computer Services.
// 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
@ -24,17 +24,16 @@
// <summary></summary>
// ***********************************************************************
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace FCS.Lib.Utility
namespace FCS.Lib.Utility;
/// <summary>
/// Vat format validator
/// </summary>
public static class VatFormatValidator
{
/// <summary>
/// Vat format validator
/// </summary>
public static class VatFormatValidator
{
// https://ec.europa.eu/taxation_customs/vies/faqvies.do#item_11
// https://ec.europa.eu/taxation_customs/vies/
@ -85,7 +84,7 @@ namespace FCS.Lib.Utility
// C8 check-digit MOD11
// C1 > 0
// R = (2*C1 + 7*C2 + 6*C3 + 5*C4 + 4*C5 + 3*C6 + 2*C7 + C8)
if(vatNumber.Length == 8 && long.TryParse(vatNumber, out _))
if (vatNumber.Length == 8 && long.TryParse(vatNumber, out _))
return ValidateMod11(vatNumber);
return false;
}
@ -123,7 +122,7 @@ namespace FCS.Lib.Utility
// C10 is check digit
var orgToCheck = orgNumber;
if (long.Parse(orgToCheck) == 0)
if (!long.TryParse(orgToCheck, out _))
return false;
switch (orgToCheck.Length)
@ -167,13 +166,13 @@ namespace FCS.Lib.Utility
if (ssn.Length is not 6 or 10 || int.Parse(ssn) == 0)
return false;
var y = int.Parse(ssn.Substring(0,2));
var m = int.Parse(ssn.Substring(2,2));
var d = int.Parse(ssn.Substring(4,2));
var y = int.Parse(ssn.Substring(0, 2));
var m = int.Parse(ssn.Substring(2, 2));
var d = int.Parse(ssn.Substring(4, 2));
// this calculation is only valid within 21st century
var leap = y % 4 == 0; // 2000 was a leap year;
// day
if(d is < 1 or > 31)
if (d is < 1 or > 31)
return false;
// month
switch (m)
@ -217,7 +216,6 @@ namespace FCS.Lib.Utility
{
return false;
}
}
@ -357,6 +355,4 @@ namespace FCS.Lib.Utility
// return nSum % 10 == 0;
//}
}
}