public override void Load() { try { var stream = Source.stream; // stream could be null if the request to remote config failed // if so, parser will throw an exception... which is what we want/need Data = JsonConfigurationStreamParser.Parse(stream); // because we're not using a 'using' - do we need to manually dispose? stream.Dispose(); } catch (Exception ex) { // [otherwise] swallow the exception and just default Data = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); } }
/// <summary> /// Loads the JSON data from a stream. /// </summary> /// <param name="stream">The stream to read.</param> public void Load(Stream stream) { try { Data = JsonConfigurationStreamParser.Parse(stream); } catch (JsonReaderException e) { string errorLine = string.Empty; if (stream.CanSeek) { stream.Seek(0, SeekOrigin.Begin); IEnumerable <string> streamContent; using (var streamReader = new StreamReader(stream)) { streamContent = ReadLines(streamReader); errorLine = RetrieveErrorContext(e, streamContent); } } throw new Exception("json parse exception"); } }