public static DefaultOptions GetOptions() { DefaultOptions defOp = new DefaultOptions(); AppDomain domain = AppDomain.CurrentDomain; string xmlPath = domain.BaseDirectory + "config.xml"; string jsonPath = domain.BaseDirectory + "appsettings.json"; int stop = 0; if (File.Exists(xmlPath)) { XmlParser x = new XmlParser(xmlPath); if (x.nodes is null) { stop = 1; } else { defOp = EtlXmlOptions.GetXmlOptions(x); } } else { stop = 1; } if (File.Exists(jsonPath) && stop == 1) { JsonParser j = new JsonParser(jsonPath); if (!(j.nodes is null)) { defOp = EtlJsonOptions.GetJsonOptions(j); } } return(defOp); }
public static DefaultOptions GetJsonOptions(JsonParser jp) { DefaultOptions defOp = new DefaultOptions(); defOp.sourceDirectoryPath = jp.TakeVariableValue("sourceDirectoryPath"); defOp.targetDirectoryPath = jp.TakeVariableValue("targetDirectoryPath"); defOp.targetArchivePath = jp.TakeVariableValue("targetArchivePath"); try { int key = Convert.ToInt32(jp.TakeVariableValue("key")); if (key > 0 && key < 146) { defOp.key = key; } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(defOp); }