コード例 #1
0
ファイル: Config.cs プロジェクト: yyp2003net/akka.net
        /// <summary>
        /// Retrieves a new configuration from the current configuration
        /// with the root node being the supplied path.
        /// </summary>
        /// <param name="path">The path that contains the configuration to retrieve.</param>
        /// <exception cref="InvalidOperationException">This exception is thrown if the current node is undefined.</exception>
        /// <returns>A new configuration with the root node being the supplied path.</returns>
        public virtual Config GetConfig(string path)
        {
            HoconValue value = GetNode(path);

            if (Fallback != null)
            {
                Config f = Fallback.GetConfig(path);
                if (value == null && f == null)
                {
                    return(null);
                }
                if (value == null)
                {
                    return(f);
                }

                return(new Config(new HoconRoot(value)).WithFallback(f));
            }

            if (value == null)
            {
                return(null);
            }

            return(new Config(new HoconRoot(value)));
        }
コード例 #2
0
ファイル: Config.cs プロジェクト: zz1231118/Framework
        /// <inheritdoc />
        public virtual Config?GetConfig(string path)
        {
            var value = GetNode(path);

            if (Fallback != null)
            {
                var fallback = Fallback.GetConfig(path);
                if (value == null && fallback == null)
                {
                    return(null);
                }
                if (value == null)
                {
                    return(fallback);
                }
                if (fallback == null)
                {
                    return(new Config(new HoconRoot(value)));
                }

                return(new Config(new HoconRoot(value)).WithFallback(fallback));
            }

            return(value != null ? new Config(new HoconRoot(value)) : null);
        }