Exemplo n.º 1
0
        public FileConfigProvider(string configFile)
        {
            _configFile = configFile;

            Result = new SpeedDateConfig();

            var configuration = File.ReadAllText(_configFile);
            //xmlParser is build upon TextReader which may not support a "reset" => create a new parser for each config instance everytime we call search...
            var xmlParser = new XmlParser(configuration);

            xmlParser.Search("Network", () =>
            {
                Result.Network = new NetworkConfig
                {
                    Address = xmlParser["Address"],
                    Port    = Convert.ToInt32(xmlParser["Port"])
                };
            });

            xmlParser = new XmlParser(configuration);
            xmlParser.Search("Plugins", () =>
            {
                Result.Plugins = new PluginsConfig
                {
                    Namespaces  = xmlParser["Namespaces"] ?? "*",
                    IncludeDlls = xmlParser["IncludeDlls"] ?? string.Empty
                };
            });
        }
Exemplo n.º 2
0
        public DefaultConfigProvider(NetworkConfig networkConfig,
                                     PluginsConfig pluginsConfig,
                                     IEnumerable <IConfig> additionalConfigs = null)
        {
            Result = new SpeedDateConfig
            {
                Network = networkConfig,
                Plugins = pluginsConfig
            };

            if (additionalConfigs == null)
            {
                return;
            }

            foreach (var config in additionalConfigs)
            {
                Result.Add(config);
            }
        }