Program.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using AtomicEngine;
  3. namespace AtomicTools
  4. {
  5. public class Program
  6. {
  7. public static void Main(string[] args)
  8. {
  9. for (uint i = 0; i < args.Length; i++)
  10. {
  11. if (args[i] == "--debugassembly" && i + 1 < args.Length)
  12. {
  13. var assemblyJSON = AtomicTools.InspectAssembly(args[i + 1]);
  14. Console.WriteLine(assemblyJSON);
  15. return;
  16. }
  17. }
  18. // create the service
  19. var app = NETServiceApplication.Create();
  20. // Subscribe to IPC NET commands
  21. app.SubscribeToEvent("IPCCmd", (eventType, eventData) =>
  22. {
  23. // get the command
  24. string command = eventData["command"];
  25. switch (command)
  26. {
  27. // parse assembly for component information
  28. case "parse":
  29. // Get the assembly to parse
  30. string assemblyPath = eventData["assemblyPath"];
  31. // Inspect the assembly for components
  32. var assemblyJSON = AtomicTools.InspectAssembly(assemblyPath);
  33. // Return result
  34. var vmap = new ScriptVariantMap();
  35. // FIXME: update index operator to a generic
  36. vmap.SetUInt("id", eventData.GetUInt("id"));
  37. vmap["command"] = command;
  38. vmap["result"] = assemblyJSON;
  39. AtomicNET.GetSubsystem<IPC>().SendEventToBroker("IPCCmdResult", vmap);
  40. break;
  41. // exit service
  42. case "exit":
  43. app.SendEvent("ExitRequested");
  44. break;
  45. }
  46. });
  47. // Managed code in charge of main loop
  48. while (app.RunFrame())
  49. {
  50. }
  51. // Shut 'er down
  52. app.Shutdown();
  53. }
  54. }
  55. }