Skip to content

Instantly share code, notes, and snippets.

View MessiDaGod's full-sized avatar

MessiDaGod MessiDaGod

  • Southern California
  • 13:06 (UTC -07:00)
View GitHub Profile
@MessiDaGod
MessiDaGod / IsNumeric.cs
Created July 27, 2022 17:21
Is a field/type numeric C#
private static HashSet<Type> NumericTypes = new HashSet<Type>
{
typeof(decimal), typeof(byte), typeof(sbyte), typeof(double)
,typeof(short), typeof(ushort), typeof(Single), typeof(UInt16)
,typeof(Int16), typeof(Int32), typeof(UInt32),typeof(UInt64)
,typeof(Int64), typeof(float)
};
public static bool IsNumeric(Type type)
{
@MessiDaGod
MessiDaGod / GetAssemblyTypes.cs
Created July 27, 2022 17:24
Get all types of a certain name from assembly C#
public List<Type>? GetAssemblyTypes(string typeName, string assemblyName = "Shakely")
{
List<Assembly> allAssemblies = new List<Assembly>();
List<Type> allTypes = new List<Type>();
string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
for (int i = 0; i < Directory.GetFiles(path, $"{assemblyName}*.dll").ToArray().Length; i++)
{
var dll = Assembly.LoadFile(Directory.GetFiles(path, $"{assemblyName}*.dll").ToArray()[i]);
allAssemblies.Add(dll);