static void Main(string[] args) { WindowsAgentExecutionMode executionMode = args.Contains(CommandLineArguments.StandaloneMode) ? WindowsAgentExecutionMode.Standalone : WindowsAgentExecutionMode.Service; var runner = new WindowsAgentRunner(); runner.Run(executionMode, "Azure Security of Things Agent"); }
/// <summary> /// Starts running the agent /// </summary> /// <param name="exeuctionMode">The execution mode in which the agent should operate</param> /// <param name="serviceName">The name of the service</param> public void Run(WindowsAgentExecutionMode exeuctionMode, string serviceName) { switch (exeuctionMode) { case WindowsAgentExecutionMode.Standalone: { new AgentService(serviceName).OnDebug(); break; } case WindowsAgentExecutionMode.Service: { var serviceToRun = new ServiceBase[] { new AgentService(serviceName) }; ServiceBase.Run(serviceToRun); break; } default: throw new ArgumentException("Unknown execution mode", nameof(exeuctionMode)); } }