Пример #1
0
        public List <Options> GetOptions()
        {
            string[] files = new string[50];
            files = Directory.GetFiles(@"G:\Ira\c#\FileWatcherService\FileWatcherService");
            foreach (string file in files)
            {
                if (Path.GetExtension(file) == ".json")
                {
                    option = jsonObject.Parse();
                }
                else if (Path.GetExtension(file) == ".xml")
                {
                    option = xmlObject.Parse();
                }
            }

            return(option);
        }
Пример #2
0
        public T GetOption <T>(string path) where T : new()
        {
            T option = new T();

            if (path.Contains(".xml"))
            {
                XmlParser parser = new XmlParser();
                option = parser.Parse <T>(path);
            }
            else if (path.Contains(".json"))
            {
                JsonParser parser = new JsonParser();
                option = parser.Parse <T>(path);
            }
            else
            {
                throw new IOException("Файл с неправильным расширением");
            }

            return(option);
        }
Пример #3
0
 public SystemConfiguration(string jsonFileName = null, string xmlFileName = null)
 {
     if (!_etlOptions.Equals(new List <Type>()))
     {
         _configurationFilePath = GetConfigurationFilePathByName(jsonFileName ?? _utils.GetAttribute <JsonFileNameAttribute>(this)?.Name);
         if (_configurationFilePath == null)
         {
             _configurationFilePath = GetConfigurationFilePathByName(xmlFileName ?? _utils.GetAttribute <XmlFileNameAttribute>(this)?.Name);
             if (_configurationFilePath == null)
             {
                 throw new FileNotFoundException("Configuration file was not found");
             }
             else
             {
                 _xmlParser.Parse(_configurationFilePath, _etlOptions);
             }
         }
         else
         {
             _jsonParser.Parse(_configurationFilePath, _etlOptions);
         }
         Logger.RecordStatusAsync("System configuration has been injected to the program...");
     }
 }