Beispiel #1
0
 /// <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>
 /// <returns>A new configuration with the root node being the supplied path.</returns>
 public virtual Config GetConfig(string path)
 {
     return(GetConfig(HoconPath.Parse(path)));
 }
Beispiel #2
0
 /// <summary>
 /// Determine if a HOCON configuration element exists at the specified location
 /// </summary>
 /// <param name="path">The location to check for a configuration value.</param>
 /// <returns><c>true</c> if a value was found, <c>false</c> otherwise.</returns>
 public bool HasPath(string path)
 => HasPath(HoconPath.Parse(path));
Beispiel #3
0
 static HoconPath()
 {
     Empty = new HoconPath();
 }
Beispiel #4
0
 /// <summary>
 /// Retrieves a <see cref="HoconValue"/> from a specific path.
 /// </summary>
 /// <param name="path">The path that contains the value to retrieve.</param>
 /// <returns>The <see cref="HoconValue"/> found at the location if one exists, otherwise <c>null</c>.</returns>
 public HoconValue GetValue(string path)
 => GetValue(HoconPath.Parse(path));
Beispiel #5
0
 public TimeSpan GetMillisDuration(HoconPath path, TimeSpan? @default = null, bool allowInfinite = true)
 {
     return(GetTimeSpan(path, @default, allowInfinite));
 }
Beispiel #6
0
 /// <summary>
 /// Retrieves a list of double values from the specified path in the configuration.
 /// </summary>
 /// <param name="path">The path that contains the values to retrieve.</param>
 /// <returns>The list of double values defined in the specified path.</returns>
 public IList <double> GetDoubleList(string path)
 => GetDoubleList(HoconPath.Parse(path));
Beispiel #7
0
 /// <summary>
 /// Retrieves a list of byte values from the specified path in the configuration.
 /// </summary>
 /// <param name="path">The path that contains the values to retrieve.</param>
 /// <returns>The list of byte values defined in the specified path.</returns>
 public IList <byte> GetByteList(string path)
 => GetByteList(HoconPath.Parse(path));
Beispiel #8
0
 /// <summary>
 /// Retrieves a boolean value from the specified path in the configuration.
 /// </summary>
 /// <param name="path">The path that contains the value to retrieve.</param>
 /// <param name="default">The default value to return if the value doesn't exist.</param>
 /// <returns>The boolean value defined in the specified path.</returns>
 public bool GetBoolean(string path, bool @default = false)
 => GetBoolean(HoconPath.Parse(path), @default);
Beispiel #9
0
 /// <summary>
 /// Retrieves a long value, optionally suffixed with a 'b', from the specified path in the configuration.
 /// </summary>
 /// <param name="path">The path that contains the value to retrieve.</param>
 /// <returns>The long value defined in the specified path.</returns>
 public long?GetByteSize(string path)
 => GetByteSize(HoconPath.Parse(path));
Beispiel #10
0
 /// <summary>
 /// Retrieves a string value from the specified path in the configuration.
 /// </summary>
 /// <param name="path">The path that contains the value to retrieve.</param>
 /// <param name="default">The default value to return if the value doesn't exist.</param>
 /// <returns>The string value defined in the specified path.</returns>
 public string GetString(string path, string @default = null)
 => GetString(HoconPath.Parse(path), @default);
Beispiel #11
0
        /// <inheritdoc cref="GetString(string,string)"/>
        public string GetString(HoconPath path, string @default = null)
        {
            var value = GetNode(path);

            return(ReferenceEquals(value, HoconValue.Undefined) ? @default : value.GetString());
        }
Beispiel #12
0
 public static HoconPath ToHoconPath(this string path)
 {
     return(HoconPath.Parse(path));
 }
 internal static HoconParserException Create(IHoconLineInfo lineInfo, HoconPath path, string message, Exception ex)
 {
     message = FormatMessage(lineInfo, path, message);
     return(new HoconParserException(lineInfo, message, ex));
 }
Beispiel #14
0
 public HoconField this[HoconPath path]
 => GetField(path);
Beispiel #15
0
 /// <summary>
 /// Retrieves a list of decimal values from the specified path in the configuration.
 /// </summary>
 /// <param name="path">The path that contains the values to retrieve.</param>
 /// <returns>The list of decimal values defined in the specified path.</returns>
 public IList <decimal> GetDecimalList(string path)
 => GetDecimalList(HoconPath.Parse(path));
Beispiel #16
0
 /// <summary>
 /// Retrieves an integer value from the specified path in the configuration.
 /// </summary>
 /// <param name="path">The path that contains the value to retrieve.</param>
 /// <param name="default">The default value to return if the value doesn't exist.</param>
 /// <returns>The integer value defined in the specified path.</returns>
 public int GetInt(string path, int @default = 0)
 => GetInt(HoconPath.Parse(path), @default);
Beispiel #17
0
 /// <summary>
 /// Retrieves a list of float values from the specified path in the configuration.
 /// </summary>
 /// <param name="path">The path that contains the values to retrieve.</param>
 /// <returns>The list of float values defined in the specified path.</returns>
 public IList <float> GetFloatList(string path)
 => GetFloatList(HoconPath.Parse(path));
Beispiel #18
0
 /// <summary>
 /// Retrieves a long value from the specified path in the configuration.
 /// </summary>
 /// <param name="path">The path that contains the value to retrieve.</param>
 /// <param name="default">The default value to return if the value doesn't exist.</param>
 /// <returns>The long value defined in the specified path.</returns>
 public long GetLong(string path, long @default = 0)
 => GetLong(HoconPath.Parse(path), @default);
Beispiel #19
0
 /// <summary>
 /// Retrieves a list of int values from the specified path in the configuration.
 /// </summary>
 /// <param name="path">The path that contains the values to retrieve.</param>
 /// <returns>The list of int values defined in the specified path.</returns>
 public IList <int> GetIntList(string path)
 => GetIntList(HoconPath.Parse(path));
Beispiel #20
0
 public byte GetByte(string path, byte @default = 0)
 => GetByte(HoconPath.Parse(path), @default);
Beispiel #21
0
 /// <summary>
 /// Retrieves a list of string values from the specified path in the configuration.
 /// </summary>
 /// <param name="path">The path that contains the values to retrieve.</param>
 /// <returns>The list of string values defined in the specified path.</returns>
 public IList <string> GetStringList(string path)
 => GetStringList(HoconPath.Parse(path));
Beispiel #22
0
 /// <summary>
 /// Retrieves a float value from the specified path in the configuration.
 /// </summary>
 /// <param name="path">The path that contains the value to retrieve.</param>
 /// <param name="default">The default value to return if the value doesn't exist.</param>
 /// <returns>The float value defined in the specified path.</returns>
 public float GetFloat(string path, float @default = 0)
 => GetFloat(HoconPath.Parse(path), @default);
Beispiel #23
0
        /// <inheritdoc cref="GetValue(string)"/>
        public HoconValue GetValue(HoconPath path)
        {
            HoconValue value = GetNode(path);

            return(value);
        }
Beispiel #24
0
 /// <summary>
 /// Retrieves a decimal value from the specified path in the configuration.
 /// </summary>
 /// <param name="path">The path that contains the value to retrieve.</param>
 /// <param name="default">The default value to return if the value doesn't exist.</param>
 /// <returns>The decimal value defined in the specified path.</returns>
 public decimal GetDecimal(string path, decimal @default = 0)
 => GetDecimal(HoconPath.Parse(path), @default);
Beispiel #25
0
 /// <summary>
 /// Retrieves a <see cref="TimeSpan"/> value from the specified path in the configuration.
 /// </summary>
 /// <param name="path">The path that contains the value to retrieve.</param>
 /// <param name="default">The default value to return if the value doesn't exist.</param>
 /// <param name="allowInfinite"><c>true</c> if infinite timespans are allowed; otherwise <c>false</c>.</param>
 /// <returns>The <see cref="TimeSpan"/> value defined in the specified path.</returns>
 public TimeSpan GetTimeSpan(string path, TimeSpan? @default = null, bool allowInfinite = true)
 => GetTimeSpan(HoconPath.Parse(path), @default, allowInfinite);
Beispiel #26
0
 /// <summary>
 /// Retrieves a double value from the specified path in the configuration.
 /// </summary>
 /// <param name="path">The path that contains the value to retrieve.</param>
 /// <param name="default">The default value to return if the value doesn't exist.</param>
 /// <returns>The double value defined in the specified path.</returns>
 public double GetDouble(string path, double @default = 0)
 => GetDouble(HoconPath.Parse(path), @default);
Beispiel #27
0
 /// <summary>
 /// Retrieves the backing <see cref="HoconValue"/> value of the <see cref="HoconField"/> associated with
 /// the supplied <see cref="HoconPath"/> path, relative to this object.
 /// </summary>
 /// <param name="path">The relative <see cref="HoconPath"/> path associated with
 /// the <see cref="HoconField"/> of the <see cref="HoconValue"/> value to retrieve.</param>
 /// <returns>
 /// The <see cref="HoconValue"/> value backing the <see cref="HoconField"/> field associated
 /// with the supplied key.
 /// </returns>
 /// <exception cref="ArgumentNullException">path is null</exception>
 /// <exception cref="ArgumentException">path is empty</exception>
 /// <exception cref="KeyNotFoundException">The key does not exist in the <see cref="HoconObject"/></exception>
 public HoconValue GetValue(HoconPath path)
 {
     return(GetField(path).Value);
 }
Beispiel #28
0
 /// <summary>
 /// Retrieves a list of boolean values from the specified path in the configuration.
 /// </summary>
 /// <param name="path">The path that contains the values to retrieve.</param>
 /// <returns>The list of boolean values defined in the specified path.</returns>
 public IList <Boolean> GetBooleanList(string path)
 => GetBooleanList(HoconPath.Parse(path));
Beispiel #29
0
 internal static HoconParserException Create(IHoconLineInfo lineInfo, HoconPath path, string message)
 {
     return(Create(lineInfo, path, message, null));
 }
Beispiel #30
0
 /// <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>
 /// <returns>A new configuration with the root node being the supplied path.</returns>
 public Config GetConfig(string path)
 => GetConfig(HoconPath.Parse(path));