示例#1
0
文件: Config.cs 项目: cptjazz/HOCON
        /// <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));
            }
        }
示例#2
0
        /// <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);
            }
        }
示例#3
0
        /// <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));
        }
示例#4
0
 /// <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;
 }
示例#5
0
 /// <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>())
 {
 }
示例#6
0
文件: Config.cs 项目: cptjazz/HOCON
 /// <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);
 }
示例#7
0
 /// <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);
 }