Exemple #1
0
        private static void SetConfig()
        {
            XmlDocument xDoc = new XmlDocument();

            xDoc.Load(Arg.XmlConfigFilePath);
            XmlNode root = xDoc["Root"];

            TaskName = root.GetValue("", "TaskName");
            Sanity.Requires(root["Common"] != null, $"Missing Common node.");

            WorkFolder = Path.Combine(TMP, $"{Now.ToStringPathMiddle()}_{TaskName}");
            Directory.CreateDirectory(WorkFolder);

            var taskNode = root[TaskName];

            if (taskNode != null)
            {
                string taskConfigPath = Path.Combine(WorkFolder, "Config.xml");
                taskNode.Save(taskConfigPath);
                string cfgKey = $"config{TaskName.ToLower()}";
                Sanity.Requires(ConfigDict.ContainsKey(cfgKey), $"Config for {TaskName} doesn't exist, may because of name mismatch.");
                var type = ConfigDict[cfgKey].GetType();
                Cfg = (Config)Deserialize(taskConfigPath, type);
                if (Arg.PostSetFlag)
                {
                    Cfg.PostSetConfig(Arg);
                }
            }

            var    commonNode = root["Common"];
            string commonPath = Path.Combine(WorkFolder, "Common.xml");

            commonNode.Save(commonPath);
            LCommon = (LocalCommon)Deserialize(commonPath, typeof(LocalCommon));
        }
Exemple #2
0
 public void LoadAndRun(Config cfg, LocalCommon common)
 {
     ConfigGeneral = cfg;
     Common        = common;
     SetConfig();
     Run();
 }