Modular Database Tools
Extracted all inspector code for database inspector into a single class per supported field type and wrote reflection code to invoke them automatically Removed all Aetheria-specific code from database tools Database View editor is now abstract and supports arbitrary grouping of entry types; specific users must implement their own database view
This commit is contained in:
parent
48759380c5
commit
526a737a4d
72 changed files with 1674 additions and 1624 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public static class CultCacheExtensions
|
||||
|
|
@ -56,7 +57,35 @@ public static class CultCacheExtensions
|
|||
return ChildClasses[type] = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(ass => ass.GetTypes()).Where(type.IsAssignableFrom).ToArray();
|
||||
}
|
||||
|
||||
private static Dictionary<Type,Type[]> GenericChildClasses = new Dictionary<Type, Type[]>();
|
||||
public static Type[] GetAllGenericChildClasses(this Type genericType)
|
||||
{
|
||||
if (GenericChildClasses.ContainsKey(genericType))
|
||||
return ChildClasses[genericType];
|
||||
return ChildClasses[genericType] = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(ass => ass.GetTypes()).Where(type=>type.IsAssignableToGenericType(genericType)).ToArray();
|
||||
}
|
||||
|
||||
public static bool IsAssignableToGenericType(this Type givenType, Type genericType)
|
||||
{
|
||||
var interfaceTypes = givenType.GetInterfaces();
|
||||
|
||||
foreach (var it in interfaceTypes)
|
||||
{
|
||||
if (it.IsGenericType && it.GetGenericTypeDefinition() == genericType)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (givenType.IsGenericType && givenType.GetGenericTypeDefinition() == genericType)
|
||||
return true;
|
||||
|
||||
Type baseType = givenType.BaseType;
|
||||
if (baseType == null) return false;
|
||||
|
||||
return IsAssignableToGenericType(baseType, genericType);
|
||||
}
|
||||
|
||||
public static async void WrapAwait(this Task task)
|
||||
{
|
||||
await task;
|
||||
|
|
|
|||
Loading…
Reference in a new issue