using System;
using System.Reflection;
using Cobilas.Collections;
namespace Cobilas {
/// Utility static class to obtain type or assembly.
public static class TypeUtilitarian {
/// Get all types of assembly.
public static Type[] GetTypes() {
Type[] types = Array.Empty();
Assembly[] assemblies = GetAssemblies();
foreach (var item in assemblies)
ArrayManipulation.Add(item.GetTypes(), ref types);
return types;
}
/// Checks if the type exists.
/// The full name of the type. (example:System.String)
public static bool TypeExist(string fullName) {
foreach (var item in GetTypes())
if (item.Name == fullName)
return true;
return false;
}
/// Get a specific type.
/// The full name of the type. (example:System.String)
public static Type GetType(string fullName) {
foreach (Type item in GetTypes())
if (item.FullName == fullName)
return item;
return null;
}
/// Get all assemblies for the current domain.
public static Assembly[] GetAssemblies()
=> AppDomain.CurrentDomain.GetAssemblies();
}
}