/// <summary> /// Retreives configuration from command line arguments. /// </summary> /// <param name="arguments">Command line args.</param> /// <returns>Config from command line args.</returns> public static ServerConfig LoadFromArguments(string[] arguments) { var config = new ServerConfig(); for (var i = 0; i < arguments.Length; i++) { switch (arguments[i]) { case "-port": { try { config.ServerPort = arguments[++i]; } catch (Exception e) { throw e; } break; } case "-backup": { config.IsBackup = true; break; } case "-t": { try { var value = arguments[++i]; config.ComponentTimeout = int.Parse(value); } catch (Exception e) { throw e; } break; } } } return config; }
/// <summary> /// /// </summary> /// <param name="configuration">Server config from App.config and arguments.</param> public CommunicationsServer(ServerConfig configuration) { _listeningPort = configuration.ServerPort; _backupMode = configuration.IsBackup; _componentTimeout = configuration.ComponentTimeout; }