static void Main(string[] args) { try { AppDomain.CurrentDomain.UnhandledException += (s, e) => { Console.WriteLine("Exception Handled: {0}", e.ExceptionObject.ToString()); }; bool isHelpRequested = IsArgumentFlagExists(args, "help", "-help", "--help", "?", "/?", "-?"); if (isHelpRequested || args.Length < 2) //config and mode are required { PrintUsage(); return; } _liquidConfig = GetArgumentValue(args, "config", (s) => { var configPath = (new FileInfo(s)).FullName; var config = LoadConfigFromFile <LiquidBridgeConfig>(configPath); config.LiquidsoapSocketsPath = (new FileInfo(config.LiquidsoapSocketsPath)).FullName; config.LiquidsoapTemplatePath = (new FileInfo(config.LiquidsoapTemplatePath)).FullName; return(config); }); if (_liquidConfig is null) { throw new ArgumentException("config is required.", "config"); } var mode = GetArgumentValue <Mode>(args, "mode", (s) => { Mode mode = Mode.None; if (!Enum.TryParse <Mode>(s, true, out mode)) { throw new ArgumentOutOfRangeException("mode"); } return(mode); }); var callWavPath = GetArgumentValue(args, "wav", (s) => { return((new FileInfo(s)).FullName); }); var callJsonPath = GetArgumentValue(args, "json", (s) => { return((new FileInfo(s)).FullName); }); var importCsvPath = GetArgumentValue(args, "csv", (s) => { return((new FileInfo(s)).FullName); }); switch (mode) { case Mode.Direct: HandleDirectMode(callWavPath, callJsonPath, _cancellationTokenSource.Token); break; case Mode.Client: HandleClientMode(callWavPath, callJsonPath, _cancellationTokenSource.Token); break; case Mode.Server: HandleServerMode(); break; case Mode.Import: HandleImportMode(importCsvPath); break; default: throw new ArgumentOutOfRangeException("mode"); } } catch (Exception e) { System.Console.WriteLine("Exception: {0}", e.ToString()); } }
public CallHandler(LiquidBridgeConfig liquidBridgeConfig, ISignalRadioClient client = null) { _liquidBridgeConfig = liquidBridgeConfig ?? throw new ArgumentNullException(nameof(liquidBridgeConfig)); _client = client ?? new SignalRadioClient(new Uri(liquidBridgeConfig.ConnectionString)); }