using System.Configuration; namespace CryptoCalc { public class Util { private static readonly decimal lowestUnit = 1e18m; public static string GetConnectionString(string name = "Default") { return ConfigurationManager.ConnectionStrings[name].ConnectionString; } public static ulong ConvToULong(decimal value) { return decimal.ToUInt64(value * lowestUnit); } public static decimal ConvToDecimal(ulong value) { return value / lowestUnit; } public static (long wholeNumber, ulong fractionNumber) SplitDecimal(decimal value) { long w = (long)value; ulong f = ConvToULong((value % 1)); return (w, f); } public static decimal CombineDecimal(long amount, ulong amountDecimal) { return amount + ConvToDecimal(amountDecimal); } } }