DllHelper.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Reflection;
  5. namespace Model
  6. {
  7. public static class DllHelper
  8. {
  9. public static Type[] GetBaseTypes()
  10. {
  11. List<Type> types = new List<Type>();
  12. Assembly[] assemblies = Game.EntityEventManager.GetAssemblies();
  13. foreach (Assembly assembly in assemblies)
  14. {
  15. Type[] t = assembly.GetTypes();
  16. types.AddRange(t);
  17. }
  18. return types.ToArray();
  19. }
  20. public static Type[] GetHotfixTypes()
  21. {
  22. ILRuntime.Runtime.Enviorment.AppDomain appDomain = Game.EntityEventManager.AppDomain;
  23. if (appDomain == null)
  24. {
  25. return new Type[0];
  26. }
  27. return appDomain.LoadedTypes.Values.Select(x => x.ReflectionType).ToArray();
  28. }
  29. public static object CreateHotfixObject(Type type)
  30. {
  31. object obj = Game.EntityEventManager.AppDomain.Instantiate(type.FullName);
  32. return obj;
  33. }
  34. public static T CreateHotfixObject<T>(Type type) where T: class
  35. {
  36. T obj = Game.EntityEventManager.AppDomain.Instantiate<T>(type.FullName);
  37. return obj;
  38. }
  39. }
  40. }