private static unsafe bool StringToLong(string str, int *parsePos, int flags, out long result, ref GuidResult parseResult) { result = 0L; try { result = ParseNumbers.StringToLong(str, 0x10, flags, parsePos); } catch (OverflowException exception) { if (parseResult.throwStyle == GuidParseThrowStyle.All) { throw; } if (parseResult.throwStyle == GuidParseThrowStyle.AllButOverflow) { throw new FormatException(Environment.GetResourceString("Format_GuidUnrecognized"), exception); } parseResult.SetFailure(exception); return(false); } catch (Exception exception2) { if (parseResult.throwStyle != GuidParseThrowStyle.None) { throw; } parseResult.SetFailure(exception2); return(false); } return(true); }
private static bool StringToInt(String str, ref int parsePos, int requiredLength, int flags, out int result, ref GuidResult parseResult) { result = 0; int currStart = parsePos; try { result = ParseNumbers.StringToInt(str, 16, flags, ref parsePos); } catch (OverflowException ex) { if (parseResult._throwStyle == GuidParseThrowStyle.All) { throw; } else if (parseResult._throwStyle == GuidParseThrowStyle.AllButOverflow) { throw new FormatException(SR.Format_GuidUnrecognized, ex); } else { parseResult.SetFailure(ex); return(false); } } catch (Exception ex) { if (parseResult._throwStyle == GuidParseThrowStyle.None) { parseResult.SetFailure(ex); return(false); } else { throw; } } //If we didn't parse enough characters, there's clearly an error. if (requiredLength != -1 && parsePos - currStart != requiredLength) { parseResult.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidInvalidChar)); return(false); } return(true); }
private static unsafe bool StringToLong(String str, ref int parsePos, int flags, out long result, ref GuidResult parseResult) { result = 0; try { result = ParseNumbers.StringToLong(str, 16, flags, ref parsePos); } catch (OverflowException ex) { if (parseResult._throwStyle == GuidParseThrowStyle.All) { throw; } else if (parseResult._throwStyle == GuidParseThrowStyle.AllButOverflow) { throw new FormatException(SR.Format_GuidUnrecognized, ex); } else { parseResult.SetFailure(ex); return(false); } } catch (Exception ex) { if (parseResult._throwStyle == GuidParseThrowStyle.None) { parseResult.SetFailure(ex); return(false); } else { throw; } } return(true); }
private static unsafe bool StringToInt(string str, int *parsePos, int requiredLength, int flags, out int result, ref GuidResult parseResult) { result = 0; int num = (parsePos == null) ? 0 : parsePos[0]; try { result = ParseNumbers.StringToInt(str, 0x10, flags, parsePos); } catch (OverflowException exception) { if (parseResult.throwStyle == GuidParseThrowStyle.All) { throw; } if (parseResult.throwStyle == GuidParseThrowStyle.AllButOverflow) { throw new FormatException(Environment.GetResourceString("Format_GuidUnrecognized"), exception); } parseResult.SetFailure(exception); return(false); } catch (Exception exception2) { if (parseResult.throwStyle != GuidParseThrowStyle.None) { throw; } parseResult.SetFailure(exception2); return(false); } if (((requiredLength != -1) && (parsePos != null)) && ((parsePos[0] - num) != requiredLength)) { parseResult.SetFailure(ParseFailureKind.Format, "Format_GuidInvalidChar"); return(false); } return(true); }
// Check if it's of the form [{|(]dddddddd-dddd-dddd-dddd-dddddddddddd[}|)] private static bool TryParseGuidWithDashes(String guidString, ref GuidResult result) { int startPos = 0; int temp; long templ; int currentPos = 0; // check to see that it's the proper length if (guidString[0] == '{') { if (guidString.Length != 38 || guidString[37] != '}') { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidInvLen)); return(false); } startPos = 1; } else if (guidString[0] == '(') { if (guidString.Length != 38 || guidString[37] != ')') { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidInvLen)); return(false); } startPos = 1; } else if (guidString.Length != 36) { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidInvLen)); return(false); } if (guidString[8 + startPos] != '-' || guidString[13 + startPos] != '-' || guidString[18 + startPos] != '-' || guidString[23 + startPos] != '-') { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidDashes)); return(false); } currentPos = startPos; if (!StringToInt(guidString, ref currentPos, 8, ParseNumbers.NoSpace, out temp, ref result)) { return(false); } result._parsedGuid._a = temp; ++currentPos; //Increment past the '-'; if (!StringToInt(guidString, ref currentPos, 4, ParseNumbers.NoSpace, out temp, ref result)) { return(false); } result._parsedGuid._b = (short)temp; ++currentPos; //Increment past the '-'; if (!StringToInt(guidString, ref currentPos, 4, ParseNumbers.NoSpace, out temp, ref result)) { return(false); } result._parsedGuid._c = (short)temp; ++currentPos; //Increment past the '-'; if (!StringToInt(guidString, ref currentPos, 4, ParseNumbers.NoSpace, out temp, ref result)) { return(false); } ++currentPos; //Increment past the '-'; startPos = currentPos; if (!StringToLong(guidString, ref currentPos, ParseNumbers.NoSpace, out templ, ref result)) { return(false); } if (currentPos - startPos != 12) { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidInvLen)); return(false); } result._parsedGuid._d = (byte)(temp >> 8); result._parsedGuid._e = (byte)(temp); temp = (int)(templ >> 32); result._parsedGuid._f = (byte)(temp >> 8); result._parsedGuid._g = (byte)(temp); temp = (int)(templ); result._parsedGuid._h = (byte)(temp >> 24); result._parsedGuid._i = (byte)(temp >> 16); result._parsedGuid._j = (byte)(temp >> 8); result._parsedGuid._k = (byte)(temp); return(true); }
// Check if it's of the form dddddddddddddddddddddddddddddddd private static bool TryParseGuidWithNoStyle(String guidString, ref GuidResult result) { int startPos = 0; int temp; long templ; int currentPos = 0; if (guidString.Length != 32) { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidInvLen)); return(false); } for (int i = 0; i < guidString.Length; i++) { char ch = guidString[i]; if (ch >= '0' && ch <= '9') { continue; } else { char upperCaseCh = Char.ToUpperInvariant(ch); if (upperCaseCh >= 'A' && upperCaseCh <= 'F') { continue; } } result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidInvalidChar)); return(false); } if (!StringToInt(guidString.Substring(startPos, 8) /*first DWORD*/, -1, ParseNumbers.IsTight, out result._parsedGuid._a, ref result)) { return(false); } startPos += 8; if (!StringToShort(guidString.Substring(startPos, 4), -1, ParseNumbers.IsTight, out result._parsedGuid._b, ref result)) { return(false); } startPos += 4; if (!StringToShort(guidString.Substring(startPos, 4), -1, ParseNumbers.IsTight, out result._parsedGuid._c, ref result)) { return(false); } startPos += 4; if (!StringToInt(guidString.Substring(startPos, 4), -1, ParseNumbers.IsTight, out temp, ref result)) { return(false); } startPos += 4; currentPos = startPos; if (!StringToLong(guidString, ref currentPos, ParseNumbers.NoSpace, out templ, ref result)) { return(false); } if (currentPos - startPos != 12) { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidInvLen)); return(false); } result._parsedGuid._d = (byte)(temp >> 8); result._parsedGuid._e = (byte)(temp); temp = (int)(templ >> 32); result._parsedGuid._f = (byte)(temp >> 8); result._parsedGuid._g = (byte)(temp); temp = (int)(templ); result._parsedGuid._h = (byte)(temp >> 24); result._parsedGuid._i = (byte)(temp >> 16); result._parsedGuid._j = (byte)(temp >> 8); result._parsedGuid._k = (byte)(temp); return(true); }
// Check if it's of the form {0xdddddddd,0xdddd,0xdddd,{0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd}} private static bool TryParseGuidWithHexPrefix(String guidString, ref GuidResult result) { int numStart = 0; int numLen = 0; // Eat all of the whitespace guidString = EatAllWhitespace(guidString); // Check for leading '{' if (String.IsNullOrEmpty(guidString) || guidString[0] != '{') { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidBrace)); return(false); } // Check for '0x' if (!IsHexPrefix(guidString, 1)) { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidHexPrefix), "{0xdddddddd, etc}"); return(false); } // Find the end of this hex number (since it is not fixed length) numStart = 3; numLen = guidString.IndexOf(',', numStart) - numStart; if (numLen <= 0) { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidComma)); return(false); } if (!StringToInt(guidString.Substring(numStart, numLen) /*first DWORD*/, -1, ParseNumbers.IsTight, out result._parsedGuid._a, ref result)) { return(false); } // Check for '0x' if (!IsHexPrefix(guidString, numStart + numLen + 1)) { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidHexPrefix), "{0xdddddddd, 0xdddd, etc}"); return(false); } // +3 to get by ',0x' numStart = numStart + numLen + 3; numLen = guidString.IndexOf(',', numStart) - numStart; if (numLen <= 0) { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidComma)); return(false); } // Read in the number if (!StringToShort(guidString.Substring(numStart, numLen) /*first DWORD*/, -1, ParseNumbers.IsTight, out result._parsedGuid._b, ref result)) { return(false); } // Check for '0x' if (!IsHexPrefix(guidString, numStart + numLen + 1)) { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidHexPrefix), "{0xdddddddd, 0xdddd, 0xdddd, etc}"); return(false); } // +3 to get by ',0x' numStart = numStart + numLen + 3; numLen = guidString.IndexOf(',', numStart) - numStart; if (numLen <= 0) { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidComma)); return(false); } // Read in the number if (!StringToShort(guidString.Substring(numStart, numLen) /*first DWORD*/, -1, ParseNumbers.IsTight, out result._parsedGuid._c, ref result)) { return(false); } // Check for '{' if (guidString.Length <= numStart + numLen + 1 || guidString[numStart + numLen + 1] != '{') { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidBrace)); return(false); } // Prepare for loop numLen++; byte[] bytes = new byte[8]; for (int i = 0; i < 8; i++) { // Check for '0x' if (!IsHexPrefix(guidString, numStart + numLen + 1)) { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidHexPrefix), "{... { ... 0xdd, ...}}"); return(false); } // +3 to get by ',0x' or '{0x' for first case numStart = numStart + numLen + 3; // Calculate number length if (i < 7) // first 7 cases { numLen = guidString.IndexOf(',', numStart) - numStart; if (numLen <= 0) { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidComma)); return(false); } } else // last case ends with '}', not ',' { numLen = guidString.IndexOf('}', numStart) - numStart; if (numLen <= 0) { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidBraceAfterLastNumber)); return(false); } } // Read in the number int signedNumber; if (!StringToInt(guidString.Substring(numStart, numLen), -1, ParseNumbers.IsTight, out signedNumber, ref result)) { return(false); } uint number = (uint)signedNumber; // check for overflow if (number > 255) { result.SetFailure(ParseFailureKind.Format, nameof(SR.Overflow_Byte)); return(false); } bytes[i] = (byte)number; } result._parsedGuid._d = bytes[0]; result._parsedGuid._e = bytes[1]; result._parsedGuid._f = bytes[2]; result._parsedGuid._g = bytes[3]; result._parsedGuid._h = bytes[4]; result._parsedGuid._i = bytes[5]; result._parsedGuid._j = bytes[6]; result._parsedGuid._k = bytes[7]; // Check for last '}' if (numStart + numLen + 1 >= guidString.Length || guidString[numStart + numLen + 1] != '}') { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidEndBrace)); return(false); } // Check if we have extra characters at the end if (numStart + numLen + 1 != guidString.Length - 1) { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_ExtraJunkAtEnd)); return(false); } return(true); }
private static bool TryParseGuid(String g, GuidStyles flags, ref GuidResult result) { if (g == null) { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidUnrecognized)); return(false); } String guidString = g.Trim(); //Remove Whitespace if (guidString.Length == 0) { result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidUnrecognized)); return(false); } // Check for dashes bool dashesExistInString = (guidString.IndexOf('-', 0) >= 0); if (dashesExistInString) { if ((flags & (GuidStyles.AllowDashes | GuidStyles.RequireDashes)) == 0) { // dashes are not allowed result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidUnrecognized)); return(false); } } else { if ((flags & GuidStyles.RequireDashes) != 0) { // dashes are required result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidUnrecognized)); return(false); } } // Check for braces bool bracesExistInString = (guidString.IndexOf('{', 0) >= 0); if (bracesExistInString) { if ((flags & (GuidStyles.AllowBraces | GuidStyles.RequireBraces)) == 0) { // braces are not allowed result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidUnrecognized)); return(false); } } else { if ((flags & GuidStyles.RequireBraces) != 0) { // braces are required result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidUnrecognized)); return(false); } } // Check for parenthesis bool parenthesisExistInString = (guidString.IndexOf('(', 0) >= 0); if (parenthesisExistInString) { if ((flags & (GuidStyles.AllowParenthesis | GuidStyles.RequireParenthesis)) == 0) { // parenthesis are not allowed result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidUnrecognized)); return(false); } } else { if ((flags & GuidStyles.RequireParenthesis) != 0) { // parenthesis are required result.SetFailure(ParseFailureKind.Format, nameof(SR.Format_GuidUnrecognized)); return(false); } } try { // let's get on with the parsing if (dashesExistInString) { // Check if it's of the form [{|(]dddddddd-dddd-dddd-dddd-dddddddddddd[}|)] return(TryParseGuidWithDashes(guidString, ref result)); } else if (bracesExistInString) { // Check if it's of the form {0xdddddddd,0xdddd,0xdddd,{0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd}} return(TryParseGuidWithHexPrefix(guidString, ref result)); } else { // Check if it's of the form dddddddddddddddddddddddddddddddd return(TryParseGuidWithNoStyle(guidString, ref result)); } } catch (IndexOutOfRangeException ex) { result.SetFailure(ParseFailureKind.FormatWithInnerException, nameof(SR.Format_GuidUnrecognized), null, null, ex); return(false); } catch (ArgumentException ex) { result.SetFailure(ParseFailureKind.FormatWithInnerException, nameof(SR.Format_GuidUnrecognized), null, null, ex); return(false); } }
private static bool TryParseGuidWithDashes(string guidString, ref GuidResult result) { int num2; long num3; int num = 0; int parsePos = 0; if (guidString[0] == '{') { if ((guidString.Length != 0x26) || (guidString[0x25] != '}')) { result.SetFailure(ParseFailureKind.Format, "Format_GuidInvLen"); return(false); } num = 1; } else if (guidString[0] == '(') { if ((guidString.Length != 0x26) || (guidString[0x25] != ')')) { result.SetFailure(ParseFailureKind.Format, "Format_GuidInvLen"); return(false); } num = 1; } else if (guidString.Length != 0x24) { result.SetFailure(ParseFailureKind.Format, "Format_GuidInvLen"); return(false); } if (((guidString[8 + num] != '-') || (guidString[13 + num] != '-')) || ((guidString[0x12 + num] != '-') || (guidString[0x17 + num] != '-'))) { result.SetFailure(ParseFailureKind.Format, "Format_GuidDashes"); return(false); } parsePos = num; if (!StringToInt(guidString, ref parsePos, 8, 0x2000, out num2, ref result)) { return(false); } result.parsedGuid._a = num2; parsePos++; if (!StringToInt(guidString, ref parsePos, 4, 0x2000, out num2, ref result)) { return(false); } result.parsedGuid._b = (short)num2; parsePos++; if (!StringToInt(guidString, ref parsePos, 4, 0x2000, out num2, ref result)) { return(false); } result.parsedGuid._c = (short)num2; parsePos++; if (!StringToInt(guidString, ref parsePos, 4, 0x2000, out num2, ref result)) { return(false); } parsePos++; num = parsePos; if (!StringToLong(guidString, ref parsePos, 0x2000, out num3, ref result)) { return(false); } if ((parsePos - num) != 12) { result.SetFailure(ParseFailureKind.Format, "Format_GuidInvLen"); return(false); } result.parsedGuid._d = (byte)(num2 >> 8); result.parsedGuid._e = (byte)num2; num2 = (int)(num3 >> 0x20); result.parsedGuid._f = (byte)(num2 >> 8); result.parsedGuid._g = (byte)num2; num2 = (int)num3; result.parsedGuid._h = (byte)(num2 >> 0x18); result.parsedGuid._i = (byte)(num2 >> 0x10); result.parsedGuid._j = (byte)(num2 >> 8); result.parsedGuid._k = (byte)num2; return(true); }
private static bool TryParseGuidWithNoStyle(string guidString, ref GuidResult result) { int num2; long num3; int startIndex = 0; int parsePos = 0; if (guidString.Length != 0x20) { result.SetFailure(ParseFailureKind.Format, "Format_GuidInvLen"); return(false); } for (int i = 0; i < guidString.Length; i++) { char c = guidString[i]; if ((c < '0') || (c > '9')) { char ch2 = char.ToUpper(c, CultureInfo.InvariantCulture); if ((ch2 < 'A') || (ch2 > 'F')) { result.SetFailure(ParseFailureKind.Format, "Format_GuidInvalidChar"); return(false); } } } if (!StringToInt(guidString.Substring(startIndex, 8), -1, 0x1000, out result.parsedGuid._a, ref result)) { return(false); } startIndex += 8; if (!StringToShort(guidString.Substring(startIndex, 4), -1, 0x1000, out result.parsedGuid._b, ref result)) { return(false); } startIndex += 4; if (!StringToShort(guidString.Substring(startIndex, 4), -1, 0x1000, out result.parsedGuid._c, ref result)) { return(false); } startIndex += 4; if (!StringToInt(guidString.Substring(startIndex, 4), -1, 0x1000, out num2, ref result)) { return(false); } startIndex += 4; parsePos = startIndex; if (!StringToLong(guidString, ref parsePos, startIndex, out num3, ref result)) { return(false); } if ((parsePos - startIndex) != 12) { result.SetFailure(ParseFailureKind.Format, "Format_GuidInvLen"); return(false); } result.parsedGuid._d = (byte)(num2 >> 8); result.parsedGuid._e = (byte)num2; num2 = (int)(num3 >> 0x20); result.parsedGuid._f = (byte)(num2 >> 8); result.parsedGuid._g = (byte)num2; num2 = (int)num3; result.parsedGuid._h = (byte)(num2 >> 0x18); result.parsedGuid._i = (byte)(num2 >> 0x10); result.parsedGuid._j = (byte)(num2 >> 8); result.parsedGuid._k = (byte)num2; return(true); }
private static bool TryParseGuidWithHexPrefix(string guidString, ref GuidResult result) { int startIndex = 0; int length = 0; guidString = EatAllWhitespace(guidString); if (string.IsNullOrEmpty(guidString) || (guidString[0] != '{')) { result.SetFailure(ParseFailureKind.Format, "Format_GuidBrace"); return(false); } if (!IsHexPrefix(guidString, 1)) { result.SetFailure(ParseFailureKind.Format, "Format_GuidHexPrefix", "{0xdddddddd, etc}"); return(false); } startIndex = 3; length = guidString.IndexOf(',', startIndex) - startIndex; if (length <= 0) { result.SetFailure(ParseFailureKind.Format, "Format_GuidComma"); return(false); } if (!StringToInt(guidString.Substring(startIndex, length), -1, 0x1000, out result.parsedGuid._a, ref result)) { return(false); } if (!IsHexPrefix(guidString, (startIndex + length) + 1)) { result.SetFailure(ParseFailureKind.Format, "Format_GuidHexPrefix", "{0xdddddddd, 0xdddd, etc}"); return(false); } startIndex = (startIndex + length) + 3; length = guidString.IndexOf(',', startIndex) - startIndex; if (length <= 0) { result.SetFailure(ParseFailureKind.Format, "Format_GuidComma"); return(false); } if (!StringToShort(guidString.Substring(startIndex, length), -1, 0x1000, out result.parsedGuid._b, ref result)) { return(false); } if (!IsHexPrefix(guidString, (startIndex + length) + 1)) { result.SetFailure(ParseFailureKind.Format, "Format_GuidHexPrefix", "{0xdddddddd, 0xdddd, 0xdddd, etc}"); return(false); } startIndex = (startIndex + length) + 3; length = guidString.IndexOf(',', startIndex) - startIndex; if (length <= 0) { result.SetFailure(ParseFailureKind.Format, "Format_GuidComma"); return(false); } if (!StringToShort(guidString.Substring(startIndex, length), -1, 0x1000, out result.parsedGuid._c, ref result)) { return(false); } if ((guidString.Length <= ((startIndex + length) + 1)) || (guidString[(startIndex + length) + 1] != '{')) { result.SetFailure(ParseFailureKind.Format, "Format_GuidBrace"); return(false); } length++; byte[] buffer = new byte[8]; for (int i = 0; i < 8; i++) { if (!IsHexPrefix(guidString, (startIndex + length) + 1)) { result.SetFailure(ParseFailureKind.Format, "Format_GuidHexPrefix", "{... { ... 0xdd, ...}}"); return(false); } startIndex = (startIndex + length) + 3; if (i < 7) { length = guidString.IndexOf(',', startIndex) - startIndex; if (length <= 0) { result.SetFailure(ParseFailureKind.Format, "Format_GuidComma"); return(false); } } else { length = guidString.IndexOf('}', startIndex) - startIndex; if (length <= 0) { result.SetFailure(ParseFailureKind.Format, "Format_GuidBraceAfterLastNumber"); return(false); } } uint num4 = (uint)Convert.ToInt32(guidString.Substring(startIndex, length), 0x10); if (num4 > 0xff) { result.SetFailure(ParseFailureKind.Format, "Overflow_Byte"); return(false); } buffer[i] = (byte)num4; } result.parsedGuid._d = buffer[0]; result.parsedGuid._e = buffer[1]; result.parsedGuid._f = buffer[2]; result.parsedGuid._g = buffer[3]; result.parsedGuid._h = buffer[4]; result.parsedGuid._i = buffer[5]; result.parsedGuid._j = buffer[6]; result.parsedGuid._k = buffer[7]; if ((((startIndex + length) + 1) >= guidString.Length) || (guidString[(startIndex + length) + 1] != '}')) { result.SetFailure(ParseFailureKind.Format, "Format_GuidEndBrace"); return(false); } if (((startIndex + length) + 1) != (guidString.Length - 1)) { result.SetFailure(ParseFailureKind.Format, "Format_ExtraJunkAtEnd"); return(false); } return(true); }
private static bool TryParseGuid(string g, GuidStyles flags, ref GuidResult result) { if (g == null) { result.SetFailure(ParseFailureKind.Format, "Format_GuidUnrecognized"); return(false); } string guidString = g.Trim(); if (guidString.Length == 0) { result.SetFailure(ParseFailureKind.Format, "Format_GuidUnrecognized"); return(false); } bool flag = guidString.IndexOf('-', 0) >= 0; if (flag) { if ((flags & (GuidStyles.DigitFormat | GuidStyles.AllowDashes)) == GuidStyles.None) { result.SetFailure(ParseFailureKind.Format, "Format_GuidUnrecognized"); return(false); } } else if ((flags & GuidStyles.DigitFormat) != GuidStyles.None) { result.SetFailure(ParseFailureKind.Format, "Format_GuidUnrecognized"); return(false); } bool flag2 = guidString.IndexOf('{', 0) >= 0; if (flag2) { if ((flags & (GuidStyles.RequireBraces | GuidStyles.AllowBraces)) == GuidStyles.None) { result.SetFailure(ParseFailureKind.Format, "Format_GuidUnrecognized"); return(false); } } else if ((flags & GuidStyles.RequireBraces) != GuidStyles.None) { result.SetFailure(ParseFailureKind.Format, "Format_GuidUnrecognized"); return(false); } if (guidString.IndexOf('(', 0) >= 0) { if ((flags & (GuidStyles.RequireParenthesis | GuidStyles.AllowParenthesis)) == GuidStyles.None) { result.SetFailure(ParseFailureKind.Format, "Format_GuidUnrecognized"); return(false); } } else if ((flags & GuidStyles.RequireParenthesis) != GuidStyles.None) { result.SetFailure(ParseFailureKind.Format, "Format_GuidUnrecognized"); return(false); } try { if (flag) { return(TryParseGuidWithDashes(guidString, ref result)); } if (flag2) { return(TryParseGuidWithHexPrefix(guidString, ref result)); } return(TryParseGuidWithNoStyle(guidString, ref result)); } catch (IndexOutOfRangeException exception) { result.SetFailure(ParseFailureKind.FormatWithInnerException, "Format_GuidUnrecognized", null, null, exception); return(false); } catch (ArgumentException exception2) { result.SetFailure(ParseFailureKind.FormatWithInnerException, "Format_GuidUnrecognized", null, null, exception2); return(false); } }