first commit

This commit is contained in:
2025-08-01 14:10:44 -04:00
commit cf32cfcbcd
149 changed files with 80416 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
namespace Core.Utility;
public static class FileUtility
{
public static FileInfo GetContentFile(string contentDirectory, string fileName, bool useAssemblyDirectory = false)
{
string basePath;
//if (useAssemblyDirectory)
// basePath = AssemblyDirectory;
//else
basePath = AppDomain.CurrentDomain.BaseDirectory;
var path = Path.Combine(basePath, contentDirectory);
return new FileInfo(path + fileName);
}
//public static string AssemblyDirectory
//{
// get
// {
// var codeBase = Assembly.GetExecutingAssembly().Location;
// var uri = new UriBuilder(codeBase);
// var path = Uri.UnescapeDataString(uri.Path);
// return Path.GetDirectoryName(path);
// }
//}
}
+69
View File
@@ -0,0 +1,69 @@
namespace Core.Utility;
public static class TextUtil
{
/// <summary>
/// Get the ordinal value of positive integers.
/// </summary>
/// <remarks>
/// Only works for english-based cultures.
/// Code from: http://stackoverflow.com/questions/20156/is-there-a-quick-way-to-create-ordinals-in-c/31066#31066
/// With help: http://www.wisegeek.com/what-is-an-ordinal-number.htm
/// </remarks>
/// <param name="number">The number.</param>
/// <returns>Ordinal value of positive integers, or <see cref="int.ToString"/> if less than 1.</returns>
/// https://stackoverflow.com/a/620504/99492
public static string Ordinal(this int number)
{
const string TH = "th";
string s = number.ToString();
// Negative and zero have no ordinal representation
if (number < 1)
{
return s;
}
number %= 100;
if ((number >= 11) && (number <= 13))
{
return s + TH;
}
switch (number % 10)
{
case 1: return s + "st";
case 2: return s + "nd";
case 3: return s + "rd";
default: return s + TH;
}
}
public static void ConsoleWriteTable(
Func<int, int, bool> getVal, string rowHeader, int[] rowVars, string colHeader, int[] colVars)
{
var chl = $" {colHeader} 0".Length;
var rhl = $"{rowHeader} 0".Length + 3;
Console.Write(new string(' ', rhl));
foreach (var c in colVars)
{
Console.Write($" {colHeader} {c + 1}");
}
Console.WriteLine();
Console.WriteLine();
foreach (var r in rowVars)
{
var rhead = $"{rowHeader} {r + 1}:";
Console.Write(rhead.PadRight(rhl));
foreach (var c in colVars)
{
var v = getVal(r, c) ? "1" : " ";
Console.Write($"{v.PadLeft(chl)}");
}
Console.WriteLine();
}
Console.WriteLine();
}
}