Exemple #1
0
        /// <summary>
        ///     Converts a TomlObject into its native type.
        /// </summary>
        /// <param name="obj">The object to convert.</param>
        /// <returns>The boxed native type of the TomlObject.</returns>
        private static object TypeConvert(TomlObject obj)
        {
            var tmlType = obj.TomlType;

            switch (tmlType)
            {
            case TomlObjectType.Bool:
                return(obj.Get <bool>());

            case TomlObjectType.Float:
                return(obj.Get <float>());

            case TomlObjectType.Int:
                return(obj.Get <int>());

            case TomlObjectType.String:
                return(obj.Get <string>());

            default:
                throw new InvalidConfigurationException($"[CFG] Cannot convert {tmlType}.");
            }
        }