public bool LoadConfig() { var path = ConfigPathHelper.GetConfigFilePath(); Logger.Current.Trace("Start LoadConfig. Config file: " + path); if (!File.Exists(path)) { Logger.Current.Debug("Config file {0} does not exist", path); return(false); } try { XmlConfig xmlConfig; using (var stream = new StreamReader(path, Encoding.UTF8)) { string state = stream.ReadToEnd(); xmlConfig = state.Deserialize <XmlConfig>(); stream.Close(); } ApplyXmlConfig(xmlConfig); Logger.Current.Trace("End LoadConfig"); return(true); } catch (Exception ex) { MessageService.Current.Info("Failed to load app settings: " + ex.Message); } return(false); }
public bool LoadConfig() { var path = ConfigPathHelper.GetConfigFilePath(); Logger.Current.Trace("开始引导配置文件 " + path); if (!File.Exists(path)) { Logger.Current.Debug("配置文件 {0} 不存在", path); return(false); } try { XmlConfig xmlConfig; using (var stream = new StreamReader(path, Encoding.UTF8)) { string state = stream.ReadToEnd(); xmlConfig = state.Deserialize <XmlConfig>(); stream.Close(); } ApplyXmlConfig(xmlConfig); Logger.Current.Trace("配置文件引导结束"); return(true); } catch (Exception ex) { MessageService.Current.Info("配置引导失败,原因为: " + ex.Message); } return(false); }
private bool LoadRepository() { var path = ConfigPathHelper.GetRepositoryConfigPath(); Logger.Current.Trace("Start LoadRepository. Config file: " + path); if (!File.Exists(path)) { Logger.Current.Debug("Repository config file {0} does not exist", path); return(false); } try { XmlRepository xmlRepository; using (var stream = new StreamReader(path, Encoding.UTF8)) { string state = stream.ReadToEnd(); xmlRepository = state.Deserialize <XmlRepository>(); stream.Close(); } ApplyRepositoryConfig(xmlRepository); Logger.Current.Trace("End LoadRepository"); return(true); } catch (Exception ex) { MessageService.Current.Info("Failed to load the state of the repository: " + ex.Message); } return(false); }
private void LoadTemplates() { string path = ConfigPathHelper.GetLayoutPath(); Model.LoadTemplates(path); templateGrid1.DataSource = Model.Templates; templateGrid1.Adapter.SelectFirstRecord(); }
private static string GetBasePath(SyncfusionSerializationType type) { switch (type) { case SyncfusionSerializationType.DockPanel: return ConfigPathHelper.GetDockingConfigPath(); case SyncfusionSerializationType.ToolBar: return ConfigPathHelper.GetToolbarConfigPath(); default: throw new ArgumentOutOfRangeException("type"); } }
private string GetSaveFilename(IWin32Window parent) { using (var dlg = new SaveFileDialog { Filter = PrintingConstants.TemplateFilter }) { dlg.InitialDirectory = ConfigPathHelper.GetLayoutPath(); if (dlg.ShowDialog(parent) == DialogResult.OK) { return(dlg.FileName); } } return(string.Empty); }
protected override object OnCreate(string configName, Type type) { string fileFullPath = ConfigPathHelper.GetConfigFileFullPath(configName); object obj = LocalConfigurationManager.Instance.GetConfigInstance(fileFullPath, type); if (obj != null) { return(obj); } //download from remote! DownloadRemoteConfig(GenerateUniqueConfigName(configName, type)); return(LocalConfigurationManager.Instance.GetConfigInstance(fileFullPath, type)); }
public override void Load() { var data = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); var environmentVariables = _environmentVariableProvider.List(_environmentVariableTarget); foreach (var i in _environmentVariableParsers) { string value = i.Value(environmentVariables); if (!string.IsNullOrEmpty(value)) { string key = ConfigPathHelper.GetPathOfConfig(i.Key); data[key] = value; } } Data = data; }
private void DownloadRemoteConfig(string configName_Type_Key) { //get remote config download func var func = _RemoteFunctions.SafeGet <string, Func <object> >(configName_Type_Key) ?? throw new KeyNotFoundException($"The Configuration key[{configName_Type_Key}] is not registered!"); string fileFullPath = ConfigPathHelper.GetConfigFileFullPath(configName_Type_Key.Substring(0, configName_Type_Key.IndexOf(ConfigurationConst.SPLITE_SYMBOL))); string tmpFile = fileFullPath + "." + Guid.NewGuid().ToString("N"); try { _logger.LogDebug($"config '{fileFullPath}' pulling..."); //get remote config var config = func.Invoke(); SaveToFile(tmpFile, config); //backup //BackUpConfig(fileFullPath); //this sucks, but this is to reduce the confliction of writing and reading // because of sucks of Windows, the copyfile is non-transaction. // we must remove the file before change its name!!! if (File.Exists(fileFullPath)) { File.Delete(fileFullPath); } File.Move(tmpFile, fileFullPath); _logger.LogDebug($"config '{fileFullPath}' pull success."); } catch (Exception ex) { _logger.LogError(ex, $"config '{fileFullPath}' pull error"); } finally { if (File.Exists(tmpFile)) { File.Delete(tmpFile); } } }
public bool SaveConfig() { try { using (var stream = new StreamWriter(ConfigPathHelper.GetConfigFilePath(), false)) { string state = GetXmlConfig().Serialize(false); stream.Write(state); stream.Flush(); stream.Close(); return(true); } } catch (Exception ex) { const string msg = "Failed to save app config."; Logger.Current.Error(msg, ex); MessageService.Current.Info(msg); } return(false); }
private bool SaveRepository() { _repository.PrepareToSave(); try { using (var stream = new StreamWriter(ConfigPathHelper.GetRepositoryConfigPath(), false)) { var state = new XmlRepository(_repository).Serialize(false); stream.Write(state); stream.Flush(); stream.Close(); return(true); } } catch (Exception ex) { const string msg = "Failed to save the state of the repository."; Logger.Current.Error(msg, ex); MessageService.Current.Info(msg); } return(false); }
private static string GetXmlPath(string url) { url = url.Replace('/', '_').Replace(':', '_'); return(ConfigPathHelper.GetWmsCachePath() + url + ".xml"); }
protected override object OnCreate(string configName, Type type) { return(GetConfigInstance(ConfigPathHelper.GetConfigFileFullPath(configName), type)); }
/// <summary> /// Gets path of the file with configuration info for the driver. /// </summary> private static string GetConfigPath(this DatasourceDriver driver) { return(ConfigPathHelper.GetDriversConfigPath() + driver.Name + ".xml"); }
/// <summary> /// Gets path of the file with configuration information for the tool. /// </summary> private static string GetConfigPath(this IGisTool tool) { return(ConfigPathHelper.GetToolsConfigPath() + tool.Name + ".xml"); }
private static string GetXmlPath(string url) { url = System.Uri.UnescapeDataString(url.Replace('/', '_').Replace(':', '_').Replace('?', '_')); return(ConfigPathHelper.GetWmsCachePath() + url + ".xml"); }