private IPathEntry GetPathEntry(string path) { IPathEntry pathEntry; if (!_entryMap.TryGetValue(path, out pathEntry)) //cache miss { try { if (_config.HasPath(path)) //found something { try { var configValue = _config.GetValue(path); if (configValue == null) //empty { pathEntry = EmptyPathEntry; } else if (configValue.IsString()) //is a string value { pathEntry = new StringPathEntry(true, true, configValue.AtKey("cached"), configValue.GetString()); } else //some other type of HOCON value { pathEntry = new ValuePathEntry(true, true, configValue.AtKey("cached")); } } catch (Exception ex) { pathEntry = EmptyPathEntry; } } else //couldn't find the path { pathEntry = NonExistingPathEntry; } } catch (Exception ex) //configuration threw some sort of error { pathEntry = InvalidPathEntry; } if (_entryMap.TryAdd(path, pathEntry)) { return(pathEntry); } else { return(_entryMap[path]); } } //cache hit return(pathEntry); }
private IPathEntry GetPathEntry(string path) { if (!_entryMap.TryGetValue(path, out var pathEntry)) //cache miss { try { if (TryGetNode(path, out var configValue)) //found something { try { if (configValue == null) //empty { pathEntry = EmptyPathEntry; } else if (configValue.Type == HoconType.String) //is a string value { pathEntry = new StringPathEntry(true, true, new Config(configValue.AtKey("cached")), configValue.GetString()); } else //some other type of HOCON value { pathEntry = new ValuePathEntry(true, true, new Config(configValue.AtKey("cached"))); } } catch (Exception) { pathEntry = EmptyPathEntry; } } else //couldn't find the path { pathEntry = NonExistingPathEntry; } } catch (Exception) //configuration threw some sort of error { pathEntry = InvalidPathEntry; } if (_entryMap.TryAdd(path, pathEntry)) { return(pathEntry); } return(_entryMap[path]); } //cache hit return(pathEntry); }
private IPathEntry GetPathEntry(string path) { IPathEntry pathEntry; if (!_entryMap.TryGetValue(path, out pathEntry)) //cache miss { try { if (_config.HasPath(path)) //found something { try { var configValue = _config.GetValue(path); if (configValue == null) //empty { pathEntry = EmptyPathEntry; } else if (configValue.IsString()) //is a string value { pathEntry = new StringPathEntry(true, true, configValue.AtKey("cached"), configValue.GetString()); } else //some other type of HOCON value { pathEntry = new ValuePathEntry(true, true, configValue.AtKey("cached")); } } catch (Exception) { pathEntry = EmptyPathEntry; } } else //couldn't find the path { pathEntry = NonExistingPathEntry; } } catch (Exception) //configuration threw some sort of error { pathEntry = InvalidPathEntry; } if (_entryMap.TryAdd(path, pathEntry)) { return pathEntry; } else { return _entryMap[path]; } } //cache hit return pathEntry; }