Exemplo n.º 1
0
 // used in WebData download.config.xml LocalConfig PrintList1Config PrintList2Config (DownloadAutomate_f.cs)
 // optional : false throw error if config file dont exist, true create empty XmlConfig if config file dont exist
 public XmlConfig GetConfig(string xpath, bool optional = false)
 {
     //string file = GetExplicit(xpath);
     //if (!zPath.IsPathRooted(file))
     //    file = zPath.Combine(zPath.GetDirectoryName(_xmlConfig.ConfigPath), file);
     string file = GetExplicit(xpath).zRootPath(zPath.GetDirectoryName(_xmlConfig.ConfigFile));
     //if (!zFile.Exists(file))
     //    throw new pb.PBException("file does'nt exists \"{0}\"", file);
     XmlConfigFile configFile;
     if (!_configFiles.ContainsKey(file))
     {
         if (!zFile.Exists(file))
         {
             if (optional)
                 configFile = new XmlConfigFile { Config = new XmlConfig(), FileTime = DateTime.Now };
             else
                 throw new pb.PBException("file does'nt exists \"{0}\"", file);
         }
         else
             configFile = new XmlConfigFile { Config = new XmlConfig(file), FileTime = zFile.GetLastWriteTime(file) };
         _configFiles.Add(file, configFile);
     }
     else
     {
         configFile = _configFiles[file];
         DateTime fileTime = zFile.GetLastWriteTime(file);
         if (fileTime > configFile.FileTime)
             configFile.Config = new XmlConfig(file);
     }
     return configFile.Config;
 }
Exemplo n.º 2
0
 // used in WebData download.config.xml LocalConfig PrintList1Config PrintList2Config (DownloadAutomate_f.cs)
 // optional : false throw error if config file dont exist, true create empty XmlConfig if config file dont exist
 public XmlConfig GetConfig(string xpath, bool optional = false)
 {
     //string file = GetExplicit(xpath);
     //if (!zPath.IsPathRooted(file))
     //    file = zPath.Combine(zPath.GetDirectoryName(_xmlConfig.ConfigPath), file);
     string file = GetExplicit(xpath).zRootPath(zPath.GetDirectoryName(_xmlConfig.ConfigFile));
     //if (!zFile.Exists(file))
     //    throw new pb.PBException("file does'nt exists \"{0}\"", file);
     XmlConfigFile configFile;
     if (!_configFiles.ContainsKey(file))
     {
         if (!zFile.Exists(file))
         {
             if (optional)
                 configFile = new XmlConfigFile { Config = new XmlConfig(), FileTime = DateTime.Now };
             else
                 throw new pb.PBException("file does'nt exists \"{0}\"", file);
         }
         else
             configFile = new XmlConfigFile { Config = new XmlConfig(file), FileTime = zFile.GetLastWriteTime(file) };
         _configFiles.Add(file, configFile);
     }
     else
     {
         configFile = _configFiles[file];
         DateTime fileTime = zFile.GetLastWriteTime(file);
         if (fileTime > configFile.FileTime)
             configFile.Config = new XmlConfig(file);
     }
     return configFile.Config;
 }