public ETLJSONOptions(string json) : base() { ETLOptions options = ParserJson.DeserializeJson <ETLOptions>(json); ArchiveOptions = options.ArchiveOptions; CrypterOptions = options.CrypterOptions; FolderOptions = options.FolderOptions; LogOptions = options.LogOptions; }
public ETLXMLOptions(string xml) : base() { ETLOptions options = ParserXml.DeserializeXml <ETLOptions>(xml); ArchiveOptions = options.ArchiveOptions; CrypterOptions = options.CrypterOptions; FolderOptions = options.FolderOptions; LogOptions = options.LogOptions; }
public Watcher() { string appDirectory = AppDomain.CurrentDomain.BaseDirectory; optionsManager = new OptionsManager(appDirectory); ETLOptions options = optionsManager.GetOptions <ETLOptions>() as ETLOptions; SDir = options.FolderOptions.SourceDir; TDir = options.FolderOptions.TargetDir; saveArchive = options.ArchiveOptions.ArchiveDir; Logger.loggerOptions = options.LogOptions; Logger.loaded = true; watcher = new FileSystemWatcher(SDir); watcher.Created += Created; }
Options FindOption <T>(ETLOptions options) { if (typeof(T) == typeof(ETLOptions)) { return(options); } try { return(options.GetType().GetProperty(typeof(T).Name).GetValue(options, null) as Options); } catch { Logger.Log("FindOption didn't find the needed option and throw a NotImplementedException."); throw new NotImplementedException(); } }
public OptionsManager(string path) { string options; try { using (StreamReader sr = new StreamReader($"{path}\\appsettings.json")) { options = sr.ReadToEnd(); } jsonOptions = new ETLJSONOptions(options); isJsonConfigured = true; Logger.Log("appsettings.json is loaded."); } catch (Exception ex) { isJsonConfigured = false; Logger.Log(ex.Message); } try { using (StreamReader sr = new StreamReader($"{path}\\config.xml")) { options = sr.ReadToEnd(); } xmlOptions = new ETLXMLOptions(options); isXmlConfigured = true; Logger.Log("config.xml is loaded."); } catch (Exception ex) { isXmlConfigured = false; Logger.Log(ex.Message); } if (!isJsonConfigured && !isXmlConfigured) { defaultOptions = new ETLOptions(); Logger.Log("Default options is used."); } }