Program.cs 1.7 KB

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