/// <summary> /// Converts the string representation of a COMB to the equivalent /// <see cref="Comb"/> structure provided that the string is in the /// specified format. /// </summary> /// <param name="input">The string to convert.</param> /// <param name="format"> /// One of the following specifiers that indicates the exact format to /// use when interpreting input: "N", "D", "B", "P", or "X". /// </param> /// <param name="result"> /// The structure that will contain the parsed value. If the method /// returns <see langword="true"/>, <paramref name="result"/> contains a /// valid <see cref="Comb"/>. If the method returns /// <see langword="false"/>, <paramref name="result"/> equals <see cref="Comb.Empty"/>. /// </param> /// <returns> /// <see langword="true"/> if the parse operation was successful; /// otherwise, <see langword="false"/>. /// </returns> /// <remarks> /// <para> /// This method returns <see langword="false"/> if /// <paramref name="input"/> is <see langword="null"/> or not in a /// recognized format and doesn't throw an exception. /// </para> /// <para> /// The following table shows the accepted format specifiers for the /// <paramref name="format"/> parameter. "0" represents a digit; hyphens /// ("-"), braces ("{", "}"), and parentheses ("(", ")") appear as shown. /// </para> /// <list type="table"> /// <listheader> /// <term>Specifier</term> /// <term>Format of return value</term> /// </listheader> /// <item> /// <term>N</term> /// <description> /// <para>32 digits:</para> /// <para>00000000000000000000000000000000</para> /// </description> /// </item> /// <item> /// <term>D</term> /// <description> /// <para>32 digits separated by hyphens:</para> /// <para>00000000-0000-0000-0000-000000000000</para> /// </description> /// </item> /// <item> /// <term>B</term> /// <description> /// <para>32 digits separated by hyphens, enclosed in braces:</para> /// <para>{00000000-0000-0000-0000-000000000000}</para> /// </description> /// </item> /// <item> /// <term>P</term> /// <description> /// <para>32 digits separated by hyphens, enclosed in parentheses:</para> /// <para>(00000000-0000-0000-0000-000000000000)</para> /// </description> /// </item> /// <item> /// <term>X</term> /// <description> /// <para> /// Four hexadecimal values enclosed in braces, where the fourth value /// is a subset of eight hexadecimal values that is also enclosed in braces: /// </para> /// <para>{0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}</para> /// </description> /// </item> /// </list> /// </remarks> public static bool TryParseExact(string input, string format, out Comb result) { if (input == null || format == null) { result = Empty; return(false); } var parser = new CombParser(input); return(parser.Parse(ParseFormat(format), out result)); }
/// <summary> /// Converts the string representation of a COMB to the equivalent /// <see cref="Comb"/> structure. /// </summary> /// <param name="input">The string to convert.</param> /// <param name="result"> /// The structure that will contain the parsed value. If the method /// returns <see langword="true"/>, <paramref name="result"/> contains a /// valid <see cref="Comb"/>. If the method returns /// <see langword="false"/>, <paramref name="result"/> equals <see cref="Comb.Empty"/>. /// </param> /// <returns> /// <see langword="true"/> if the parse operation was successful; /// otherwise, <see langword="false"/>. /// </returns> /// <remarks> /// <para> /// This method is like the <see cref="Parse"/> method, except that /// instead of returning the parsed COMB, it returns /// <see langword="false"/> if <paramref name="input"/> is /// <see langword="null"/> or not in a recognized format and doesn't /// throw an exception. It converts strings in any of the five formats /// produced by the <see cref="ToString(String)"/> and /// <see cref="ToString(String, IFormatProvider)"/> methods, as shown in /// the following table. /// </para> /// <list type="table"> /// <listheader> /// <term>Specifier</term> /// <term>Description</term> /// <term>Format</term> /// </listheader> /// <item> /// <term>N</term> /// <description>32 digits</description> /// <description>00000000000000000000000000000000</description> /// </item> /// <item> /// <term>D</term> /// <description>32 digits separated by hyphens</description> /// <description>00000000-0000-0000-0000-000000000000</description> /// </item> /// <item> /// <term>B</term> /// <description> /// 32 digits separated by hyphens, enclosed in braces /// </description> /// <description>{00000000-0000-0000-0000-000000000000}</description> /// </item> /// <item> /// <term>P</term> /// <description> /// 32 digits separated by hyphens, enclosed in parentheses /// </description> /// <description>(00000000-0000-0000-0000-000000000000)</description> /// </item> /// <item> /// <term>X</term> /// <description> /// Four hexadecimal values enclosed in braces, where the fourth value /// is a subset of eight hexadecimal values that is also enclosed in braces /// </description> /// <description>{0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}</description> /// </item> /// </list> /// </remarks> public static bool TryParse(string input, out Comb result) { if (input == null) { result = Empty; return(false); } var parser = new CombParser(input); return(parser.Parse(out result)); }