Exemple #1
0
        public void Load(string filePath)
        {
            FullPath = filePath;

            var stream = new YamlStream();

            using (var reader = new StreamReader(filePath))
            {
                stream.Load(reader);
                var doc = stream.Documents[0];

                var map = doc.RootNode as YamlMappingNode;

                if (map.ContainsKey("logging"))
                {
                    Logging.FromYaml(doc.RootNode["logging"]);
                }
                else
                {
                    _logger.Log(Level.Warning, "Missing logging section. Default values shall be used.");
                }

                if (map.ContainsKey("plugins"))
                {
                    Plugins.FromYaml(doc.RootNode["plugins"]);
                }
                else
                {
                    _logger.Log(Level.Error, "Missing plugins section. Exit.");
                    throw new InvalidFilterCriteriaException("Missing plugin section in main configuration file.");
                }

                if (map.ContainsKey("file"))
                {
                    FileInformation.FromYaml(doc.RootNode["file"]);
                }
                else
                {
                    _logger.Log(Level.Error, "Missing file information section in main adapter file.  Probably older configuration file is being used.");
                }

                reader.DiscardBufferedData();
                reader.BaseStream.Seek(0, SeekOrigin.Begin);
                CheckSum = Utility.Utils.ChecksumForString(reader.ReadToEnd());
            }
        }