public static BuffersConfiguration LoadConfigurationFromAppConfig() { ServerConfigurationSection serverConfigurationSection = (ServerConfigurationSection)ConfigurationManager.GetSection("server"); BuffersConfiguration buffersConfiguration = new BuffersConfiguration { Provider = serverConfigurationSection.Buffers.Provider }; return(buffersConfiguration); }
private static void Main(string[] args) { CommunicationServer communicationServer; try { var config = ServerConfigurationSection.LoadConfig("serverConfig", args); var serverAddress = IpEndPointParser.Parse(config.Address, config.Port); var timeout = config.Timeout; var isBackup = config.IsBackup; IPEndPoint masterServerAddress; if (isBackup) { masterServerAddress = IpEndPointParser.Parse(config.MasterServer.Address, config.MasterServer.Port); } //_logger.Info("Server address: " + serverAddress); var serverConfig = new ServerConfig { Mode = isBackup ? ServerConfig.ServerMode.Backup : ServerConfig.ServerMode.Primary, Address = serverAddress, CommunicationTimeout = timeout }; communicationServer = new CommunicationServer(serverConfig); } catch (Exception ex) { var errorText = string.Format("{0}:{1}", ex.GetType().FullName, ex.Message); if (ex.InnerException != null) { errorText += string.Format("|({0}:{1})", ex.InnerException.GetType().FullName, ex.InnerException.Message); } //_logger.Error(errorText); return; } communicationServer.Start(); while (Console.ReadLine() != "exit") { // input handling } communicationServer.Stop(); }
/// <summary> /// Loads the server configuration. /// </summary> private void LoadServerConfiguration() { _domain = ConfigurationManager.AppSettings["domain"]; _defaultIp = ConfigurationManager.AppSettings["defaultIp"]; _includeWww = (ConfigurationManager.AppSettings["includeWww"].Equals("true", StringComparison.InvariantCultureIgnoreCase)) ? true : false; ServerConfigurationSection servers = (ServerConfigurationSection)ConfigurationManager.GetSection("serverConfigSection"); if (servers != null) { foreach (ServerElement element in servers.Elements) { this.Add(new ServerHostsFileConfiguration(element.Name, GenerateDnsEntries(element.IpMask, element.Pool))); } } }
public static ProcessingConfiguration LoadConfigurationFromAppConfig() { ServerConfigurationSection serverConfigurationSection = (ServerConfigurationSection)ConfigurationManager.GetSection("server"); ProcessingConfigurationElement processingConfig = serverConfigurationSection.Processing; Dictionary <string, CommandProcessingConfiguration> commandOverrrides = processingConfig.Commands .Cast <CommandConfigurationElement>() .ToDictionary(element => element.Name, CommandProcessingConfiguration.Create); ProcessingConfiguration processingConfiguration = new ProcessingConfiguration { MaxMessageBodySize = processingConfig.MaxMessageBodySize, HeaderReadingTimeout = processingConfig.HeaderReadingTimeout, MessageRecieveTimeout = processingConfig.MessageRecieveTimeout, ResponseSendingTimeout = processingConfig.ResponseSendingTimeout, CommandOverrides = new ReadOnlyDictionary <string, CommandProcessingConfiguration>(commandOverrrides) }; return(processingConfiguration); }
public static ListenerConfiguration LoadConfigurationFromAppConfig() { ServerConfigurationSection serverConfigurationSection = (ServerConfigurationSection)ConfigurationManager.GetSection("server"); var listenerConfig = serverConfigurationSection.Listener; MessageTransportKind messageTransport = listenerConfig.MessageTransport == "AsyncApi" ? MessageTransportKind.AsyncApi : MessageTransportKind.NetworkStream; ListenerConfiguration listenerConfiguration = new ListenerConfiguration { Transport = messageTransport, EndPoint = new IPEndPoint(IPAddress.Any, Glvar.PORT_MAIN), ConnectionCapacity = listenerConfig.ConnectionCapacity, InitialAcceptsCount = listenerConfig.InitialAcceptsCount, ListenBacklog = listenerConfig.ListenBacklog, ListenSocketReceiveBufferSize = listenerConfig.ListenSocketReceiveBufferSize, ListenSocketSendBufferSize = listenerConfig.ListenSocketSendBufferSize, ClientSocketReceiveBufferSize = listenerConfig.ClientSocketReceiveBufferSize, ClientSocketSendBufferSize = listenerConfig.ClientSocketSendBufferSize }; return listenerConfiguration; }