protected virtual void LoadConfiguration() { var configNode = this.GetConfigurationNode(); Assert.IsNotNull(configNode, "Root LiveBlog config node not found. Missing LiveBlog.config?"); var defaultProvider = configNode.SelectSingleNode("./commandParserProviders")?.Attributes?["defaultProvider"]?.Value ?? "default"; var configurationNodes = configNode.SelectNodes("./commandParserProviders/commandParser"); // no configs let's get outta here if (configurationNodes == null || configurationNodes.Count == 0) { this.commandParserProviders = new ICommandParserConfigurtation[0]; return; } var providers = new Collection <ICommandParserConfigurtation>(); var nameChecker = new HashSet <string>(StringComparer.OrdinalIgnoreCase); foreach (XmlElement element in configurationNodes) { var configuration = this.LoadCommandParserConfigurtation(element); if (nameChecker.Contains(configuration.Name)) { throw new InvalidOperationException("The LiveBlog CommandParserProvider '" + configuration.Name + "' is defined twice. Configurations should have unique names."); } nameChecker.Add(configuration.Name); if (configuration.Name.Equals(defaultProvider)) { this.defaultCommandParserProvider = configuration; } providers.Add(configuration); } this.commandParserProviders = providers.ToArray(); }
protected virtual void LoadConfiguration() { var configNode = this.GetConfigurationNode(); Assert.IsNotNull(configNode, "Root LiveBlog config node not found. Missing LiveBlog.config?"); var defaultProvider = configNode.SelectSingleNode("./commandParserProviders")?.Attributes?["defaultProvider"]?.Value ?? "default"; var configurationNodes = configNode.SelectNodes("./commandParserProviders/commandParser"); // no configs let's get outta here if (configurationNodes == null || configurationNodes.Count == 0) { this.commandParserProviders = new ICommandParserConfigurtation[0]; return; } var providers = new Collection<ICommandParserConfigurtation>(); var nameChecker = new HashSet<string>(StringComparer.OrdinalIgnoreCase); foreach (XmlElement element in configurationNodes) { var configuration = this.LoadCommandParserConfigurtation(element); if (nameChecker.Contains(configuration.Name)) { throw new InvalidOperationException("The LiveBlog CommandParserProvider '" + configuration.Name + "' is defined twice. Configurations should have unique names."); } nameChecker.Add(configuration.Name); if (configuration.Name.Equals(defaultProvider)) { this.defaultCommandParserProvider = configuration; } providers.Add(configuration); } this.commandParserProviders = providers.ToArray(); }