Beispiel #1
0
        /// <summary>
        /// Creates a new <see cref="LayoutScript"/> object from a string.
        /// </summary>
        /// <param name="source">The <see cref="LayoutScript"/> source code string.</param>
        /// <param name="format">The source code format.</param>
        /// <returns>The newly-created <see cref="LayoutScript"/> object.</returns>
        /// <exception cref="LayoutScriptException">
        /// Thrown if the <see cref="LayoutScript"/> is empty or contains a
        /// malformatted version string.
        /// </exception>
        /// <exception cref="SyntaxException">
        /// Thrown if the <see cref="LayoutScript"/> contains a syntax error.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown if the source string is empty or null.
        /// </exception>
        internal static LayoutScript Parse(string source, LayoutFormat format)
        {
            if (string.IsNullOrWhiteSpace(source))
            {
                throw new ArgumentException(Resources.ArgumentExceptionEmptyString, nameof(source));
            }

            switch (format)
            {
            case LayoutFormat.Xml:
                return(XmlLayoutScript.Parse(source));

            default:
                throw new NotSupportedException();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new <see cref="LayoutScript"/> object from a file.
        /// </summary>
        /// <param name="path">The path to the file to load.</param>
        /// <param name="format">The source code format.</param>
        /// <returns>The newly-created <see cref="LayoutScript"/> object.</returns>
        /// <exception cref="LayoutScriptException">
        /// Thrown if the <see cref="LayoutScript"/> is empty or contains a
        /// malformatted version string.
        /// </exception>
        /// <exception cref="SyntaxException">
        /// Thrown if the <see cref="LayoutScript"/> contains a syntax error.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown if the path is empty or null.
        /// </exception>
        internal static LayoutScript Load(string path, LayoutFormat format)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentException(Resources.ArgumentExceptionEmptyString, nameof(path));
            }

            switch (format)
            {
            case LayoutFormat.Xml:
                return(XmlLayoutScript.Load(path));

            default:
                // TODO: message
                throw new NotSupportedException();
            }
        }