Program.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Reflection;
  3. using AtomicEngine;
  4. namespace AtomicSharpTool
  5. {
  6. class MainClass
  7. {
  8. public static void Main (string[] args)
  9. {
  10. Assembly assembly = Assembly.LoadFrom("/Users/josh/Dev/atomic/AtomicGameEngineSharp/Build/AtomicSharp/AtomicSharpTest/bin/Debug/AtomicSharpTest.exe");
  11. Type[] types = assembly.GetTypes ();
  12. foreach (var type in types)
  13. {
  14. if (type.BaseType.Name == "CSComponent") {
  15. FieldInfo[] fields = type.GetFields ();
  16. Console.WriteLine (type.Name);
  17. object instance = null;
  18. foreach (var field in fields)
  19. {
  20. foreach (var attribute in field.GetCustomAttributes(true)) {
  21. if (attribute is InspectorAttribute) {
  22. if (instance == null)
  23. instance = Activator.CreateInstance (type);
  24. var attr = attribute as InspectorAttribute;
  25. string defaultValue = attr.DefaultValue;
  26. if (defaultValue.Length == 0 && field.GetValue (instance) != null)
  27. defaultValue = field.GetValue (instance).ToString ();
  28. Console.WriteLine ("Inspector Field: {0}, {1}, {2}", field.Name,
  29. field.FieldType.Name, defaultValue);
  30. }
  31. }
  32. }
  33. }
  34. }
  35. }
  36. }
  37. }