public static void Main(string[] args) { DefaultStartup <NetworkNode> defaultStartup = new DefaultStartup <NetworkNode>(); defaultStartup.InitArgumentParse(args); IConfigurationParser <Configuration> configurationParser; if (defaultStartup.ChooseXmlParser()) { configurationParser = new XmlConfigurationParser(defaultStartup.Filename); } else { configurationParser = new MockConfigurationParser(); } Configuration configuration = configurationParser.ParseConfiguration(); defaultStartup.InitLogger(configuration.RouterAlias); IPacketForwarder packetForwarder = new MplsPacketForwarder(); //IPacketForwarder packetForwarder = new MockPacketForwarder(configuration); IPersistentClientPortFactory <EonPacket> clientPortFactory = new PersistentClientPortFactory <EonPacket>(configuration.CableCloudAddress, configuration.CableCloudPort); IManager networkNodeManager = new NetworkNodeManager(configuration, packetForwarder, clientPortFactory); defaultStartup.SetTitle(configuration.RouterAlias); networkNodeManager.Start(); }
public static void Main(string[] args) { DefaultStartup <CableCloud> defaultStartup = new DefaultStartup <CableCloud>(); defaultStartup.InitArgumentParse(args); IConfigurationParser <Configuration> configurationParser; if (defaultStartup.ChooseXmlParser()) { configurationParser = new XmlConfigurationParser(defaultStartup.Filename); } else { configurationParser = new MockConfigurationParser(); } Configuration configuration = configurationParser.ParseConfiguration(); defaultStartup.InitLogger(null); IWorkerFactory <EonPacket> clientWorkerFactory = new WorkerFactory <EonPacket>(); IPersistentServerPort <EonPacket> serverPort = new PersistentServerPort <EonPacket>(configuration.ListeningAddress, configuration.ListeningPort, clientWorkerFactory); IPacketForwarder packetForwarder = new PacketForwarder(configuration); ICableCloudManager cableCloudManager = new CableCloudManager(serverPort, packetForwarder); ICommandParser commandParser = new CommandParser(configuration); IUserInterface userInterface = new UserInterface(commandParser, cableCloudManager); defaultStartup.SetTitle("CC"); userInterface.Start(); }
public static void Main(string[] args) { DefaultStartup <RoutingController> defaultStartup = new DefaultStartup <RoutingController>(); defaultStartup.InitArgumentParse(args); IConfigurationParser <Configuration> configurationParser; if (defaultStartup.ChooseXmlParser()) { configurationParser = new XmlConfigurationParser(defaultStartup.Filename); } else { configurationParser = new MockConfigurationParser(); } defaultStartup.InitLogger(null); Configuration configuration = configurationParser.ParseConfiguration(); IRcState rcState = new RcState(configuration.RouteTable); defaultStartup.SetTitle($"RC_{configuration.ComponentName}"); IManager routingControllerManager = new RoutingControllerManager(configuration, rcState.OnRouteTableQuery, rcState.OnLocalTopology, rcState.OnNetworkTopology); routingControllerManager.Start(); }
public void Should_parse_XmlDocument_with_overriden_root_name() { var settings = XmlConfigurationParser.Parse("<object key1='val1' key2='val2' />", "overriden"); settings.Name.Should().Be("overriden"); settings["key1"].Value.Should().Be("val1"); settings["key2"].Value.Should().Be("val2"); }
public void Should_parse_Object_from_attributes() { var settings = XmlConfigurationParser.Parse("<object key1='val1' key2='val2' />"); settings.Name.Should().Be("object"); settings["key1"].Value.Should().Be("val1"); settings["key2"].Value.Should().Be("val2"); }
static void Main(string[] args) { string filename = ""; string logs = ""; try { LOG.Trace($"Args: {string.Join(", ", args)}"); if (args[0] == "-c") { filename = args[1]; } if (args[2] == "-l") { logs = args[3]; } else { LOG.Warn("Use '-c <filename> -l <log_filename>' to pass a config file to program and set where logs should be"); } } catch (IndexOutOfRangeException) { LOG.Warn("Use '-c <filename> -l <log_filename>' to pass a config file to program and set where logs should be"); } LoggerSetup(logs); if (string.IsNullOrEmpty(filename)) { filename = "resources/config/ManagementSystem.xml"; } IConfigurationParser configurationParser = new XmlConfigurationParser(filename); Configuration configuration = configurationParser.ParseConfiguration(); try { Console.Title = "MS"; } catch (Exception) { LOG.Trace("Could not set the title"); } IManagementManager mm = new ManagementManager(); mm.ReadConfig(configuration); mm.StartListening(); MessageSender.ReadConfig(configuration); new Thread(MessageSender.SendConfigCommands).Start(); UserInterface.Start(); }
public void Should_parse_Array_from_elements_with_same_keys() { const string value = @" <ArrayParent> <Array>value1</Array> <Array>value2</Array> </ArrayParent>"; var settings = XmlConfigurationParser.Parse(value); settings.Name.Should().Be("ArrayParent"); settings["Array"].Children.Select(child => child.Value).Should().Equal("value1", "value2"); }
public void Should_parse_Object_from_subelements() { const string value = @" <Dictionary> <Key1>value1</Key1> <Key2>value2</Key2> </Dictionary>"; var settings = XmlConfigurationParser.Parse(value); settings.Name.Should().Be("Dictionary"); settings["Key1"].Value.Should().Be("value1"); settings["Key2"].Value.Should().Be("value2"); }
public void XmlTest() { var xml = @"<setting a=""3""> <b><c>4</c></b> </setting>"; using var reader = new StringReader(xml); var data = XmlConfigurationParser.Read(reader); Assert.NotNull(data); Assert.Equal(2, data.Count); Assert.Equal("3", data["a"]); Assert.Equal("4", data["b:c"]); }
public void Should_ignore_attributes_presented_in_subelements_and_add_not_presented_in_subelements() { const string value = @" <object item='value0' attr='test'> <item>value1</item> <item>value2</item> </object>"; var settings = XmlConfigurationParser.Parse(value); settings.Name.Should().Be("object"); settings["item"].Children.Select(child => child.Value).Should().Equal("value1", "value2"); settings["attr"].Value.Should().Be("test"); }
public static void Main(string[] args) { DefaultStartup <ConnectionController> defaultStartup = new DefaultStartup <ConnectionController>(); defaultStartup.InitArgumentParse(args); IConfigurationParser <Configuration> configurationParser; if (defaultStartup.ChooseXmlParser()) { configurationParser = new XmlConfigurationParser(defaultStartup.Filename); } else { configurationParser = new MockConfigurationParser(); } defaultStartup.InitLogger(null); Configuration configuration = configurationParser.ParseConfiguration(); IConnectionControllerState connectionControllerState = configuration.ConnectionControllerType switch { "node" => new ConnectionControllerStateNode(configuration.ServerAddress, configuration.CcPeerCoordinationRemotePorts, configuration.LrmRemotePorts, configuration.CcNames, configuration.NnFibInsertRemotePort, configuration.RcRouteTableQueryRemotePort), "domain" => new ConnectionControllerStateDomain(configuration.ServerAddress, configuration.CcConnectionRequestRemotePorts, configuration.CcNames), "subnetwork" => new ConnectionControllerStateSubnetwork(configuration.ServerAddress, configuration.CcPeerCoordinationRemotePorts, configuration.CcConnectionRequestRemotePorts, configuration.LrmRemotePorts, configuration.CcNames, configuration.RcRouteTableQueryRemotePort), _ => throw new Exception("Not a known ConnectionController type") }; IManager connectionControllerManager = new ConnectionControllerManager(configuration, connectionControllerState.OnConnectionRequest, connectionControllerState.OnPeerCoordination); defaultStartup.SetTitle($"CC_{configuration.ComponentName}"); connectionControllerManager.Start(); } }
public void Should_parse_Object_with_children_of_different_types() { const string value = @" <Mixed> <SingleItem>SingleValue</SingleItem> <DictItem> <DictKey>DictValue</DictKey> </DictItem> <ArrayItem>ArrayValue1</ArrayItem> <ArrayItem>ArrayValue2</ArrayItem> </Mixed>"; var settings = XmlConfigurationParser.Parse(value); settings.Name.Should().Be("Mixed"); settings["SingleItem"].Value.Should().Be("SingleValue"); settings["DictItem"]["DictKey"].Value.Should().Be("DictValue"); settings["ArrayItem"].Children.Select(child => child.Value).Should().Equal("ArrayValue1", "ArrayValue2"); }
public void Should_parse_ArrayOfObjects_value() { const string value = @" <object> <item> <subitem1>value1</subitem1> </item> <item> <subitem2>value2</subitem2> </item> </object>"; var settings = XmlConfigurationParser.Parse(value); settings.Name.Should().Be("object"); settings["item"].Children.Count().Should().Be(2); settings["item"].Children.First()["subitem1"].Value.Should().Be("value1"); settings["item"].Children.Last()["subitem2"].Value.Should().Be("value2"); }
/// <summary> /// This method is used to get the embedded configuration for this cpunode /// </summary> /// <param name="path">The path where the .xml file is supposed to be</param> /// <returns>If the configuration is loaded</returns> public bool TryToLoadConfiguration(string path) { XmlConfigurationParser parser = new XmlConfigurationParser(); EmbeddedConfig ec; try { ec = parser.FromFile(path, this); } catch (Exception e) { #if DEBUG Console.WriteLine(e); #endif return(false); } this.EmbeddedConfig = ec; return(true); }
public void Should_parse_ArrayOfArrays_value() { const string value = @" <object> <item> <subitem>value1</subitem> <subitem>value2</subitem> </item> <item> <subitem>value3</subitem> <subitem>value4</subitem> </item> </object>"; var settings = XmlConfigurationParser.Parse(value); settings.Name.Should().Be("object"); settings["item"].Children.Count().Should().Be(2); settings["item"].Children.First()["subitem"].Children.Select(c => c.Value).Should().Equal("value1", "value2"); settings["item"].Children.Last()["subitem"].Children.Select(c => c.Value).Should().Equal("value3", "value4"); }
public static void Main(string[] args) { DefaultStartup <ClientNode> defaultStartup = new DefaultStartup <ClientNode>(); defaultStartup.InitArgumentParse(args); IConfigurationParser <Configuration> configurationParser; if (defaultStartup.ChooseXmlParser()) { configurationParser = new XmlConfigurationParser(defaultStartup.Filename); } else { configurationParser = new MockConfigurationParser(); } Configuration configuration = configurationParser.ParseConfiguration(); defaultStartup.InitLogger(configuration.ClientAlias); CpccState cpccState = new CpccState(configuration.NccConnectionRequestRemoteAddress, configuration.NccConnectionRequestRemotePort, configuration.NccCallTeardownRemoteAddress, configuration.NccCallTeardownRemotePort); ICommandParser commandParser = new CommandParser(configuration); IPersistentClientPort <EonPacket> clientPort = new PersistentClientPort <EonPacket>(configuration.ClientPortAlias, configuration.CableCloudAddress, configuration.CableCloudPort); IClientNodeManager clientNodeManager = new ClientNodeManager(configuration, clientPort, cpccState.OnCallAccept); IUserInterface userInterface = new UserInterface(commandParser, clientNodeManager, cpccState, configuration.ClientAlias); defaultStartup.SetTitle(configuration.ClientAlias); userInterface.Start(); }
public static void Main(string[] args) { DefaultStartup <NetworkCallController> defaultStartup = new DefaultStartup <NetworkCallController>(); defaultStartup.InitArgumentParse(args); IConfigurationParser <Configuration> configurationParser; if (defaultStartup.ChooseXmlParser()) { configurationParser = new XmlConfigurationParser(defaultStartup.Filename); } else { configurationParser = new MockConfigurationParser(); } defaultStartup.InitLogger(null); // TODO: Set log suffix from configuration Configuration configuration = configurationParser.ParseConfiguration(); NccState nccState = new NccState(configuration.ClientPortAliases, configuration.PortDomains, configuration.Domain, configuration.ServerAddress, configuration.ConnectionRequestRemotePort, configuration.CallCoordinationRemotePort); IManager networkCallControllerManager = new NetworkCallControllerManager(configuration, nccState.OnCallCoordinationReceived, nccState.OnCallTeardownReceived, nccState.OnCallRequestReceived); // TODO: Those are only empty delegates, make proper ones: 2 left defaultStartup.SetTitle($"NCC_{configuration.Domain}"); networkCallControllerManager.Start(); }
public static void Main(string[] args) { string filename = ""; string logs = ""; try { LOG.Trace($"Args: {string.Join(", ", args)}"); if (args[0] == "-c") { filename = args[1]; } if (args[2] == "-l") { logs = args[3]; } else { LOG.Warn("Use '-c <filename> -l <log_filename>' to pass a config file to program and set where logs should be"); } } catch (IndexOutOfRangeException) { LOG.Warn("Use '-c <filename> -l <log_filename>' to pass a config file to program and set where logs should be"); LOG.Warn("Using MockConfigurationParser instead"); } IConfigurationParser configurationParser; if (string.IsNullOrWhiteSpace(filename)) { configurationParser = new MockConfigurationParser(); } else { configurationParser = new XmlConfigurationParser(filename); } Configuration configuration = configurationParser.ParseConfiguration(); LoggingConfiguration config = new LoggingConfiguration(); ColoredConsoleTarget consoleTarget = new ColoredConsoleTarget { Name = "console", Layout = "[${time} | ${level:format=FirstCharacter} | ${logger}] ${message}" }; FileTarget fileTarget = new FileTarget { FileName = logs + "/ClientNode_" + configuration.ClientAlias + ".log", DeleteOldFileOnStartup = true, Layout = "[${time} | ${level:format=FirstCharacter} | ${logger}] ${message}" }; config.AddRule(LogLevel.Trace, LogLevel.Fatal, consoleTarget); config.AddRule(LogLevel.Debug, LogLevel.Fatal, fileTarget); LogManager.Configuration = config; IClientPortFactory clientPortFactory = new ClientPortFactory(configuration); ICommandParser commandParser = new CommandParser(configuration); IClientNodeManager clientNodeManager = new ClientNodeManager(configuration, clientPortFactory); IUserInterface userInterface = new UserInterface(commandParser, clientNodeManager); try { Console.Title = configuration.ClientAlias; } catch (Exception) { LOG.Trace("Could not set the title"); } userInterface.Start(); }
public void Should_parse_single_value(string value) { var settings = XmlConfigurationParser.Parse($"<StringValue>{value}</StringValue>"); settings.Should().BeOfType <ValueNode>().Which.Value.Should().Be(value); }
public void Should_throw_XmlException_on_wrong_xml_format() { const string value = "wrong file format"; new Action(() => { XmlConfigurationParser.Parse(value); }).Should().Throw <XmlException>(); }
public void Should_return_null(string xml) { XmlConfigurationParser.Parse(xml).Should().BeNull(); }
public void Should_ignore_key_case() { var settings = XmlConfigurationParser.Parse("<root><value>string</value></root>"); settings["VALUE"].Value.Should().Be("string"); }
public override Properties GetProperties(string content) { using var reader = new StringReader(content); return(new Properties(XmlConfigurationParser.Read(reader))); }