|
|
|
@ -49,7 +49,7 @@ namespace OptionStudy.UnitApp
|
|
|
|
|
public override void Load(Stream stream)
|
|
|
|
|
{
|
|
|
|
|
var parser = new YamlFileParser();
|
|
|
|
|
Data =parser.Parse(stream);
|
|
|
|
|
Data = parser?.Parse(stream)??new Dictionary<string, string?>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -73,11 +73,11 @@ namespace OptionStudy.UnitApp
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class YamlFileParser
|
|
|
|
|
{
|
|
|
|
|
private readonly IDictionary<string, string> _data = new SortedDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
private readonly IDictionary<string, string?> _data = new SortedDictionary<string, string?>(StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
private readonly Stack<string> _context = new Stack<string>();
|
|
|
|
|
private string _currentPath;
|
|
|
|
|
private string? _currentPath;
|
|
|
|
|
|
|
|
|
|
public IDictionary<string, string> Parse(Stream input)
|
|
|
|
|
public IDictionary<string, string?> Parse(Stream input)
|
|
|
|
|
{
|
|
|
|
|
_data.Clear();
|
|
|
|
|
_context.Clear();
|
|
|
|
@ -99,7 +99,7 @@ namespace OptionStudy.UnitApp
|
|
|
|
|
|
|
|
|
|
private void VisitYamlNodePair(KeyValuePair<YamlNode, YamlNode> yamlNodePair)
|
|
|
|
|
{
|
|
|
|
|
var context = ((YamlScalarNode)yamlNodePair.Key).Value;
|
|
|
|
|
var context = ((YamlScalarNode)yamlNodePair.Key).Value??string.Empty;
|
|
|
|
|
VisitYamlNode(context, yamlNodePair.Value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -123,7 +123,7 @@ namespace OptionStudy.UnitApp
|
|
|
|
|
{
|
|
|
|
|
//a node with a single 1-1 mapping
|
|
|
|
|
EnterContext(context);
|
|
|
|
|
var currentKey = _currentPath;
|
|
|
|
|
var currentKey = _currentPath??string.Empty;
|
|
|
|
|
|
|
|
|
|
if (_data.ContainsKey(currentKey))
|
|
|
|
|
{
|
|
|
|
|