/// <summary>
        /// Loads the JSON data from a stream.
        /// </summary>
        /// <param name="stream">The stream to read.</param>
        public override void Load(Stream stream)
        {
            try
            {
                Data = NewtonsoftJsonConfigurationFileParser.Parse(stream);
            }
            catch (JsonReaderException e)
            {
                string errorLine = string.Empty;
                if (stream.CanSeek)
                {
                    stream.Seek(0, SeekOrigin.Begin);

                    IEnumerable <string> fileContent;
                    using (var streamReader = new StreamReader(stream))
                    {
                        fileContent = ReadLines(streamReader);
                        errorLine   = RetrieveErrorContext(e, fileContent);
                    }
                }

                throw new FormatException(Resources.FormatError_JSONParseError(e.LineNumber, errorLine), e);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Loads json configuration key/values from a stream into a provider.
 /// </summary>
 /// <param name="stream">The json <see cref="Stream"/> to load configuration data from.</param>
 public override void Load(Stream stream)
 {
     Data = NewtonsoftJsonConfigurationFileParser.Parse(stream);
 }