/// <summary> /// Wraps this <see cref="HoconValue"/> into a new <see cref="Config"/> object at the specified key. /// </summary> /// <param name="key">The key designated to be the new root element.</param> /// <returns>A <see cref="Config"/> with the given key as the root element.</returns> public Config AtKey(string key) { var o = new HoconObject(); o.GetOrCreateKey(key); o.Items[key] = this; var r = new HoconValue(); r.Values.Add(o); return new Config(new HoconRoot(r)); }
/// <summary> /// Retrieves the value associated with the supplied key. /// If the supplied key is not found, then one is created /// with a blank value. /// </summary> /// <param name="key">The key associated with the value to retrieve.</param> /// <returns>The value associated with the supplied key.</returns> public HoconValue GetOrCreateKey(string key) { if (Items.ContainsKey(key)) { return Items[key]; } var child = new HoconValue(); Items.Add(key, child); return child; }
/// <summary> /// Initializes a new instance of the <see cref="HoconRoot"/> class. /// </summary> /// <param name="value">The value to associate with this element.</param> public HoconRoot(HoconValue value) { Value = value; Substitutions = Enumerable.Empty<HoconSubstitution>(); }
/// <summary> /// Initializes a new instance of the <see cref="HoconRoot"/> class. /// </summary> /// <param name="value">The value to associate with this element.</param> /// <param name="substitutions">An enumeration of substitutions to associate with this element.</param> public HoconRoot(HoconValue value, IEnumerable<HoconSubstitution> substitutions) { Value = value; Substitutions = substitutions; }