private static void ParseObject( HoconValue owner, string currentPath, IConfiguration conf) { if (!owner.IsObject()) { owner.NewValue(new HoconObject()); } HoconObject hoconObject = owner.GetObject(); foreach (var section in conf.GetChildren()) { if (int.TryParse(section.Key, out _)) { if (!owner.Values[0].IsArray()) { owner.Clear(); owner.NewValue(new HoconArray()); } var array = (HoconArray)owner.Values[0]; var value = new HoconValue(); ParseSection(currentPath, section, value); array.Add(value); } else { ParseSection(currentPath, section, hoconObject.GetOrCreateKey(section.Key)); } } }
private void ParseObject(HoconValue owner, bool root, string currentPath) { if (!owner.IsObject()) { owner.NewValue(new HoconObject()); } HoconObject currentObject = owner.GetObject(); while (!_reader.EoF) { Token t = _reader.PullNext(); switch (t.Kind) { case TokenKind.Include: if (_includeCallback == null) { throw new InvalidOperationException("include callback is null"); } var included = _includeCallback(t.Value); var substitutions = included.Substitutions; foreach (var substitution in substitutions) { substitution.Path = currentPath + "." + substitution.Path; } this.substitutions.AddRange(substitutions); var otherObj = included.Value.GetObject(); owner.GetObject().Merge(otherObj); break; case TokenKind.EoF: break; case TokenKind.Key: HoconValue value = currentObject.GetOrCreateKey(t.Value); var nextPath = currentPath == "" ? t.Value : currentPath + "." + t.Value; ParseKeyContent(value, nextPath); if (!root) { return; } break; case TokenKind.ObjectEnd: return; } } }