/// <inheritdoc cref="Config(HoconValue)" /> /// <param name="source">The root node to base this configuration.</param> /// <exception cref="T:System.ArgumentNullException">"The root value cannot be null."</exception> public Config(HoconRoot source) { Value = (HoconValue)source.Value.Clone(null); if (!(source is Config cfg)) { return; } foreach (var value in cfg._fallbacks) { _fallbacks.Add((HoconValue)value.Clone(null)); } }
/// <inheritdoc cref="Config(HoconValue)" /> /// <param name="root">The root node to base this configuration.</param> /// <exception cref="T:System.ArgumentNullException">"The root value cannot be null."</exception> public Config(HoconRoot root) { Value = (HoconValue)root.Value.Clone(null); Root = (HoconValue)root.Value.Clone(null); if (!(root is Config cfg)) { return; } foreach (var value in cfg._fallbacks) { InsertFallbackValue(value); } }
/// <summary> /// Generates a configuration defined in the supplied /// HOCON (Human-Optimized Config Object Notation) string. /// </summary> /// <param name="hocon">A string that contains configuration options to use.</param> /// <param name="includeCallback">callback used to resolve includes</param> /// <returns>The configuration defined in the supplied HOCON string.</returns> public static Config ParseString(string hocon, HoconIncludeCallbackAsync includeCallback) { HoconRoot res = HoconParser.Parse(hocon, includeCallback); return(new Config(res)); }
/// <inheritdoc cref="Config()"/> /// <param name="source">The configuration to use as the primary source.</param> /// <param name="fallback">The configuration to use as a secondary source.</param> /// <exception cref="ArgumentNullException">The source configuration cannot be null.</exception> public Config(HoconRoot source, Config fallback) : base(source?.Value, source?.Substitutions ?? Enumerable.Empty <HoconSubstitution>()) { Fallback = fallback; }
/// <inheritdoc cref="Config()"/> /// <param name="root">The root node to base this configuration.</param> /// <exception cref="T:System.ArgumentNullException">"The root value cannot be null."</exception> public Config(HoconRoot root) : base(root?.Value, root?.Substitutions ?? Enumerable.Empty <HoconSubstitution>()) { }
/// <inheritdoc cref="Config(HoconValue)" /> /// <param name="source">The configuration to use as the primary source.</param> /// <param name="fallback">The configuration to use as a secondary source.</param> /// <exception cref="ArgumentNullException">The source configuration cannot be null.</exception> public Config(HoconRoot source, Config fallback) : this(source) { MergeConfig(fallback); }
/// <inheritdoc cref="Config(HoconValue)" /> /// <param name="root">The configuration to use as the primary source.</param> /// <param name="fallback">The configuration to use as a secondary source.</param> /// <exception cref="ArgumentNullException">The source configuration cannot be null.</exception> public Config(HoconRoot root, Config fallback) : this(root) { MergeConfig(fallback); }