This commit is contained in:
Michael Becker 2024-11-19 22:36:37 -05:00
parent 466ce7e5b2
commit 93f8790653
2 changed files with 15 additions and 3 deletions

View File

@ -62,6 +62,13 @@ namespace MBS.Core.Collections.Generic
list.Add(item);
}
}
public static void AddRange<TKey, TValue>(this ICollection<KeyValuePair<TKey, TValue>> list, IEnumerable<KeyValuePair<TKey, TValue>> items)
{
foreach (KeyValuePair<TKey, TValue> kvp in items)
{
list.Add(kvp);
}
}
public static T[] ToNullTerminatedArray<T>(this IEnumerable<T> enumerable) where T : class
{

View File

@ -129,12 +129,12 @@ public class TypeLoader
}
private static Type[] mvarAvailableTypes = null;
public static T[] GetAvailableTypes<T>(Assembly[] additionalAssemblies = null) where T : class
public static T[] GetAvailableTypes<T>(Assembly[] additionalAssemblies = null, bool resetCache = false) where T : class
{
Type[] ts = null;
try
{
ts = GetAvailableTypes(new Type[] { typeof(T) }, additionalAssemblies);
ts = GetAvailableTypes(new Type[] { typeof(T) }, additionalAssemblies, resetCache);
}
catch (ReflectionTypeLoadException ex)
{
@ -156,8 +156,12 @@ public class TypeLoader
}
return list.ToArray();
}
public static Type[] GetAvailableTypes(Type[] inheritsFrom = null, Assembly[] additionalAssemblies = null)
public static Type[] GetAvailableTypes(Type[] inheritsFrom = null, Assembly[] additionalAssemblies = null, bool resetCache = false)
{
if (resetCache)
{
mvarAvailableTypes = null;
}
if (mvarAvailableTypes == null)
{
List<Type> types = new List<Type>();
@ -210,6 +214,7 @@ public class TypeLoader
List<Type> retval = new List<Type>();
foreach (Type t in mvarAvailableTypes)
{
string typeFullName = t.FullName;
foreach (Type inheritsFromType in inheritsFrom)
{
if (t.FullName.Contains("Mini."))