/// <summary> /// Loads yaml configuration key/values from a stream into a provider. /// </summary> /// <param name="stream">The yaml <see cref="Stream"/> to load configuration data from.</param> public override void Load(Stream stream) { try { Data = YamlConfigurationFileParser.Parse(stream); } catch (YamlException ex) { string errorLine = string.Empty; if (stream.CanSeek) { stream.Seek(0, SeekOrigin.Begin); using (var streamReader = new StreamReader(stream)) { var fileContent = ReadLines(streamReader); errorLine = RetrieveErrorContext(ex, fileContent); } } throw new FormatException( "Could not parse the YAML file. " + $"Error on line number '{ex.Start.Line}': '{errorLine}'.", ex); } }
/// <summary> /// Loads yaml configuration key/values from a stream into a provider. /// </summary> /// <param name="stream">The yaml <see cref="Stream"/> to load configuration data from.</param> public override void Load(Stream stream) { Data = YamlConfigurationFileParser.Parse(stream); }