Exemplo n.º 1
0
        /// <summary>
        /// Formats the string using invariant culture info.
        /// </summary>
        /// <param name="format">The format string.</param>
        /// <param name="args">Arguments for the format string.</param>
        /// <returns>The formatted string.</returns>
        public static string FormatInvariant(this string format, params Object[] args)
        {
            ThrowIf.StringIsNullOrWhiteSpace(format, nameof(format));
            ThrowIf.ArgumentNull(args, nameof(args));

            return(string.Format(CultureInfo.InvariantCulture, format, args));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the XML attribute from the specified XmlNode.
        /// </summary>
        /// <param name="node">The XmlNode containing the attribute you want.</param>
        /// <param name="attributeName">The attribute name.</param>
        /// <returns>The xml attribute value.</returns>
        /// <exception cref="XmlException">There was an error parsing the XmlNode.</exception>
        public static string GetXmlAttribute(XmlNode node, string attributeName)
        {
            ThrowIf.ArgumentNull(node, nameof(node));
            ThrowIf.StringIsNullOrWhiteSpace(attributeName, nameof(attributeName));

            if (node.Attributes?[attributeName] == null)
            {
                throw new XmlException(StringUtils.FormatInvariant("No XML attribute named '{0}' was found!", attributeName));
            }

            return(node.Attributes[attributeName].Value);
        }