public bool isNumeric(string val, System.Globalization.NumberStyles NumberStyle) { Double result; return(Double.TryParse(val, NumberStyle, System.Globalization.CultureInfo.CurrentCulture, out result)); }
public bool NegTest4() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("NegTest4: test ArgumentException2"); try { string s1 = "4346"; int i1 = 54543; System.Globalization.NumberStyles Ns = (System.Globalization.NumberStyles)i1; Int32 i2 = Int32.Parse(s1, Ns); TestLibrary.TestFramework.LogError("107", "the Method did not throw a FormatException,patameter is: " + s1); retVal = false; } catch (System.ArgumentException) { } catch (Exception e) { TestLibrary.TestFramework.LogError("108", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return(retVal); }
private void t2Zoom_Validating(object sender, System.ComponentModel.CancelEventArgs e) { System.Globalization.NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign; if (t2Zoom.Text == "") { t2Zoom.Text = "0.0"; } double value; // = Convert.ToDouble(t2Zoom.Text); if (double.TryParse(t2Zoom.Text, style, System.Globalization.CultureInfo.InvariantCulture, out value)) { if (value >= -1.0 && value <= 1.0) { value = Math.Round(value); trackBarZoom.Value = (int)value; } else { e.Cancel = true; t2Zoom.SelectAll(); } } else { e.Cancel = true; t2Zoom.SelectAll(); } }
public bool NegTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("NegTest2:Test the ArgumentException"); try { String s1 = "1000"; int i1 = 54543; System.Globalization.NumberStyles Ns = (System.Globalization.NumberStyles)i1; Int32 i2 = Int32.Parse(s1, Ns, new CultureInfo("en-US")); TestLibrary.TestFramework.LogError("103", "the Method did not throw a ArgumentException,patameter is: " + s1); retVal = false; } catch (ArgumentException) { } catch (Exception e) { TestLibrary.TestFramework.LogError("104", "Unexpected exception: " + e); retVal = false; } return(retVal); }
static public Int64?SctandardNumberFormatZaalBetraagMili( string ZaalSictString, System.Globalization.NumberFormatInfo NumberFormat, System.Globalization.NumberStyles NumberStyle = NumberStyles.Number) { if (null == ZaalSictString) { return(null); } /* * 2013.07.14 * Bsp: "1.584.570" * Bsp: "8,3" * */ ZaalSictString = ZaalSictString.Trim(); double ZaalAlsDouble; if (double.TryParse( ZaalSictString, NumberStyle, NumberFormat, out ZaalAlsDouble)) { var DistanzMili = (Int64)(ZaalAlsDouble * 1e+3); return(DistanzMili); } return(null); }
/// <summary>Converts the string representation of a number to a half-precision floating-point equivalent.</summary> /// <param name="s">String representation of the number to convert.</param> /// <param name="style">Specifies the format of <paramref name="s"/>.</param> /// <param name="provider">Culture-specific formatting information.</param> /// <param name="result">The Half instance to write to.</param> /// <returns><see langword="true" /> true if parsing succeeded; otherwise <see langword="false"/>.</returns> public static bool TryParse(string s, System.Globalization.NumberStyles style, IFormatProvider provider, out Half result) { double f; bool b = Double.TryParse(s, style, provider, out f); result = new Half(f); return(b); }
/// <summary> /// /// </summary> /// <param name="s"></param> /// <param name="style"></param> /// <returns></returns> public static System.Single Parse(System.String s, System.Globalization.NumberStyles style) { if (s.EndsWith("f") || s.EndsWith("F")) { return(System.Single.Parse(s.Substring(0, s.Length - 1), style)); } else { return(System.Single.Parse(s, style)); } }
/// <summary> /// /// </summary> /// <param name="s"></param> /// <param name="style"></param> /// <param name="provider"></param> /// <returns></returns> public static float Parse(string s, System.Globalization.NumberStyles style, System.IFormatProvider provider) { if (s.EndsWith("f") || s.EndsWith("F")) { return(float.Parse(s.Substring(0, s.Length - 1), style, provider)); } else { return(float.Parse(s, style, provider)); } }
public static bool IsNumeric(this string val, System.Globalization.NumberStyles numberStyle = System.Globalization.NumberStyles.Number) { if (val.ToValueAsString().Length == 0) { return(true); } Double result; return(Double.TryParse(val, numberStyle, System.Globalization.CultureInfo.CurrentCulture, out result)); }
public static bool TryParse(string s, System.Globalization.NumberStyles style, IFormatProvider provider, out float result) { result = 0; try { result = Single.Parse(s, style, provider); return(true); } catch (Exception) { return(false); } }
private static int TryParseNonNegativeInteger(string parameterName, string value, System.Globalization.NumberStyles styles = System.Globalization.NumberStyles.Any, IFormatProvider provider = null) { provider = provider ?? CultureInfo.InvariantCulture; int n; if (int.TryParse(value, styles, provider, out n) == false) { throw new ODataException($"Query '{parameterName}' must be an integer."); } if (n < 0) { throw new ODataException($"Query '{parameterName}' must be an non-negative integer."); } return(n); }
private void trackBarTilt_Scroll(object sender, EventArgs e) { System.Globalization.NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign; if (t2Tilt.Text == "") { t2Tilt.Text = "0.0"; } double value1 = ((double)trackBarTilt.Value); double value; // = Convert.ToDouble(t2Tilt.Text); if (double.TryParse(t2Tilt.Text, style, System.Globalization.CultureInfo.InvariantCulture, out value)) { if (Math.Round(value1) != Math.Round(value)) { t2Tilt.Text = value1.ToString("0.0", System.Globalization.CultureInfo.InvariantCulture); } } }
private void trackBarZoomS_ValueChanged(object sender, EventArgs e) { System.Globalization.NumberStyles style = NumberStyles.AllowDecimalPoint; if (t2ZoomSpeed.Text == "") { t2ZoomSpeed.Text = "0.0"; } double value1 = ((double)trackBarZoomS.Value) / 10.0; double value; // = Convert.ToDouble(t2Zoom.Text); if (double.TryParse(t2ZoomSpeed.Text, style, System.Globalization.CultureInfo.InvariantCulture, out value)) { if (Math.Round(value1 * 10.0) != Math.Round(value * 10.0)) { t2ZoomSpeed.Text = value1.ToString("0.0", System.Globalization.CultureInfo.InvariantCulture); } } }
/// <summary> /// Parses the string and returns a color object. /// Throws ArgumentException if color is invalid. /// </summary> /// <param name="color">integer, hex or color name.</param> public static Color Parse(string color) { if (color == null) { throw new ArgumentNullException("color"); } if (color == "") { throw new ArgumentException("color"); } try { uint clr = 0; // Must use Enum.Parse because Enum.IsDefined is case sensitive try { object obj = Enum.Parse(typeof(ColorName), color, true); clr = (uint)obj; return(new Color(clr)); } catch { //ignore exception cause it's not a ColorName. } System.Globalization.NumberStyles numberStyle = System.Globalization.NumberStyles.Integer; string number = color.ToLower(); if (number.StartsWith("0x")) { numberStyle = System.Globalization.NumberStyles.HexNumber; number = color.Substring(2); } clr = uint.Parse(number, numberStyle); return(new Color(clr)); } catch (FormatException ex) { throw new ArgumentException(DomSR.InvalidColorString(color), ex); } }
public static OptionValue InterpretString(string s) { OptionValue r = new OptionValue(); r.String = s; string s2 = s; System.Globalization.NumberStyles ns = System.Globalization.NumberStyles.Any; if (s.StartsWith("0x")) { s2 = s.Substring(2); ns = System.Globalization.NumberStyles.HexNumber; } uint.TryParse(s2, ns, CultureInfo.InvariantCulture, out r.UInt); int.TryParse(s2, ns, CultureInfo.InvariantCulture, out r.Int); bool.TryParse(s2, out r.Bool); ulong.TryParse(s2, ns, CultureInfo.InvariantCulture, out r.ULong); long.TryParse(s2, ns, CultureInfo.InvariantCulture, out r.Long); r.Set = true; return(r); }
private void button3_Click(object sender, EventArgs e) { System.Globalization.NumberStyles ns = (System.Globalization.NumberStyles.Currency); List <Product> productsInOrder = new List <Product>(); foreach (DataGridViewRow Row in FeeEntryDGV.Rows) { if (Row.Cells[10].Value != null) { string commision = Row.Cells[4].Value.ToString(); decimal commisionNum = decimal.Parse(commision, ns); string etsyFee = Row.Cells[5].Value.ToString(); decimal etsyFeeNum = decimal.Parse(etsyFee, ns); string paymentFee = Row.Cells[6].Value.ToString(); decimal paymentFeeNum = decimal.Parse(paymentFee, ns); string totalFees = Row.Cells[7].Value.ToString(); decimal totalFeesNum = decimal.Parse(totalFees, ns); string profitBeforeShipping = Row.Cells[8].Value.ToString(); decimal profitBeforeShippingNum = decimal.Parse(profitBeforeShipping, ns); string totalProfit = Row.Cells[10].Value.ToString(); decimal totalProfitNum = decimal.Parse(totalProfit, ns); EtsyFees.AddFee(Convert.ToDecimal(Row.Cells[0].Value), Convert.ToDecimal(Row.Cells[1].Value), Convert.ToDecimal(Row.Cells[2].Value), Convert.ToInt32(Row.Cells[3].Value), commisionNum, etsyFeeNum, paymentFeeNum, totalFeesNum, profitBeforeShippingNum, Convert.ToDecimal(Row.Cells[9].Value), totalProfitNum); } } FeeEntryDGV.Rows.Clear(); SavedFeeDGV.DataSource = DataLib.GetEtsyFees(); }
extern internal static void InternalTryParseInt64(string str, string format, System.Globalization.NumberStyles style, out long value);
/// <param name="value"></param> /// <param name="style"></param> /// <param name="provider"></param> public static Real Parse(string value, System.Globalization.NumberStyles style, IFormatProvider provider) { return(new Real(Numeric.Parse(value, style, provider))); }
/// <param name="value">a floating point number</param> /// <param name="style"></param> public static Real Parse(string value, System.Globalization.NumberStyles style) { return(new Real(Numeric.Parse(value, style))); }
extern internal static double InternalParseDouble(string str, string format, System.Globalization.NumberStyles style);
public bool isNumeric(string val, System.Globalization.NumberStyles NumberStyle) { // https://www.codeproject.com/Articles/13338/Check-If-A-String-Value-Is-Numeric Double result; return(Double.TryParse(val, NumberStyle, System.Globalization.CultureInfo.CurrentCulture, out result)); }
extern internal static float InternalParseSingle(string str, string format, System.Globalization.NumberStyles style);
extern internal static long InternalParseInt64(string str, string format, System.Globalization.NumberStyles style);
extern internal static uint InternalParseUInt32(string str, string format, System.Globalization.NumberStyles style);
/// <summary> /// Attempt to find the first type of integer that a number can fit into /// </summary> /// <param name="image"></param> /// <param name="isHex"></param> /// <param name="negated"></param> /// <param name="services"></param> /// <returns></returns> public static LiteralElement Create(string image, bool isHex, bool negated, IServiceProvider services) { StringComparison comparison = StringComparison.OrdinalIgnoreCase; if (isHex == false) { // Create a real element if required LiteralElement realElement = RealLiteralElement.CreateFromInteger(image, services); if ((realElement != null)) { return(realElement); } } bool hasUSuffix = image.EndsWith("u", comparison) & !image.EndsWith("lu", comparison); bool hasLSuffix = image.EndsWith("l", comparison) & !image.EndsWith("ul", comparison); bool hasUlSuffix = image.EndsWith("ul", comparison) | image.EndsWith("lu", comparison); bool hasSuffix = hasUSuffix | hasLSuffix | hasUlSuffix; LiteralElement constant = default(LiteralElement); System.Globalization.NumberStyles numStyles = NumberStyles.Integer; if (isHex == true) { numStyles = NumberStyles.AllowHexSpecifier; image = image.Remove(0, 2); } if (hasSuffix == false) { // If the literal has no suffix, it has the first of these types in which its value can be represented: int, uint, long, ulong. constant = Int32LiteralElement.TryCreate(image, isHex, negated); if ((constant != null)) { return(constant); } constant = UInt32LiteralElement.TryCreate(image, numStyles); if ((constant != null)) { return(constant); } constant = Int64LiteralElement.TryCreate(image, isHex, negated); if ((constant != null)) { return(constant); } return(new UInt64LiteralElement(image, numStyles)); } else if (hasUSuffix == true) { image = image.Remove(image.Length - 1); // If the literal is suffixed by U or u, it has the first of these types in which its value can be represented: uint, ulong. constant = UInt32LiteralElement.TryCreate(image, numStyles); if ((constant != null)) { return(constant); } else { return(new UInt64LiteralElement(image, numStyles)); } } else if (hasLSuffix == true) { // If the literal is suffixed by L or l, it has the first of these types in which its value can be represented: long, ulong. image = image.Remove(image.Length - 1); constant = Int64LiteralElement.TryCreate(image, isHex, negated); if ((constant != null)) { return(constant); } else { return(new UInt64LiteralElement(image, numStyles)); } } else { // If the literal is suffixed by UL, Ul, uL, ul, LU, Lu, lU, or lu, it is of type ulong. Debug.Assert(hasUlSuffix == true, "expecting ul suffix"); image = image.Remove(image.Length - 2); return(new UInt64LiteralElement(image, numStyles)); } }
extern internal static sbyte InternalParseSByte(string str, string format, System.Globalization.NumberStyles style);
extern internal static void InternalTryParseDouble(string str, string format, System.Globalization.NumberStyles style, out double value);
public bool Extract(string source) { decodeException = null; BillPeriods.Clear(); DailyUsages.Clear(); DecodeErrors.Clear(); Download = 0; Upload = 0; //TotalCombined = 0; int delta = 1; Double doubleValue; System.Globalization.NumberStyles style = System.Globalization.NumberStyles.Number | System.Globalization.NumberStyles.AllowCurrencySymbol; System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-CA"); Match match; // An unexpected problem //<div[^>]+class=\"error\"[^>]*>(?<Msg>[^<]*(<br\\s*/?>)?[^<]*)</div> //match = Regex.Match(source, "<div[^>]+class=\"error\"[^>]*>(?<Msg>[^<]*(<br\\s*/?>)?[^<]*)</div>", RegexOptions.IgnoreCase); //if (match.Success) // throw new DecodeFailedException(DecodeFailedTypes.Unexpected, source) { Message = match.Groups["Msg"].Value }; //else //{ // match = Regex.Match(source, "<div[^>]+class=\"error\"[^>]*>(?<Msg>[^<]*<br\\s*/?>[^<]*)</div>", RegexOptions.IgnoreCase); // if (match.Success) // throw new DecodeFailedException(DecodeFailedTypes.Unexpected, source) { Message = match.Groups["Msg"].Value }; //} // unité //match = Regex.Match(source, "<p class=\"arrow-down-yellow\">[a-z]*<br/><span class=\"txt-medium\">\\d+(\\.|,)?\\d*\\s*( )?\\s*(?<Unit>(g|m|k)o)", RegexOptions.IgnoreCase); match = Regex.Match(source, "<input[^>]+name=\"dataVolumeUnitCode\"[^>]*value=\"(?<Unit>G|M|K)(B|O)\"[^>]*>", RegexOptions.IgnoreCase); // Contre vérification, on ne sait jamais... if (!match.Success) { match = Regex.Match(source, "<a[^>]*active[^>]*>(?<Unit>G|M|K)(O|B)</a>", RegexOptions.IgnoreCase); } if (match.Success) { if (match.Groups["Unit"].Value.ToUpper() == "G") { delta = 1048576; } else if (match.Groups["Unit"].Value.ToUpper() == "M") { delta = 1024; } } else { throw new DecodeFailedException(DecodeFailedTypes.Unit, source); } // Download //match = Regex.Match(source, "<p class=\"arrow-down-yellow\">[a-z]*<br/><span class=\"txt-medium\">(?<Download>\\d+(\\.|,)?\\d*)", RegexOptions.IgnoreCase); match = Regex.Match(source, @"download_label[^0-9]+(?<Download>[0-9,\.]+)", RegexOptions.IgnoreCase); if (match.Success && Double.TryParse(match.Groups["Download"].Value, style, culture, out doubleValue)) { Download = doubleValue * delta; } else { throw new DecodeFailedException(DecodeFailedTypes.Download, source); } // Upload //match = Regex.Match(source, "<p class=\"arrow-up-blue\">[a-z]*<br/><span class=\"txt-medium\">(?<Upload>\\d+(\\.|,)?\\d*)", RegexOptions.IgnoreCase); match = Regex.Match(source, @"upload_label[^0-9]+(?<Upload>[0-9,\.]+)", RegexOptions.IgnoreCase); if (match.Success && Double.TryParse(match.Groups["Upload"].Value, style, culture, out doubleValue)) { Upload = doubleValue * delta; } else { throw new DecodeFailedException(DecodeFailedTypes.Upload, source); } // TotalCombined //match = Regex.Match(source, "<p><span class=\"txt-emphasized\">[a-z]*</span><br/><span class=\"txt-medium\">(?<TotalCombined>\\d+(\\.|,)?\\d*)", RegexOptions.IgnoreCase); /*match = Regex.Match(source, @"total_label[^0-9]+(?<TotalCombined>[0-9,\.]+)", RegexOptions.IgnoreCase); * if (match.Success && Double.TryParse(match.Groups["TotalCombined"].Value, style, culture, out doubleValue)) * TotalCombined = doubleValue * delta; * else * throw new DecodeFailedException(DecodeFailedTypes.TotalCombined, source);*/ // Période affiché // <h3>Usage from December 4, 2010 to January 3, 2011</h3> // <h3>Usagefrom December 4, 2010 to January 3, 2011</h3> // <h3>Votre consommation internetdu 4 décembre 2010 au 3 janvier 2011</h3> //match = Regex.Match(source, "<h3>Votre consommation internetdu (?<PeriodStartDay>[0-9]+) (?<PeriodStartMonth>[a-zéû]+) au (?<PeriodEndDay>[0-9]+) (?<PeriodEndMonth>[a-zéû]+) (?<PeriodEndYear>[0-9]{4})", RegexOptions.IgnoreCase); match = Regex.Match(source, @"<h3>Usage\s*from\s*(?<PeriodStartMonth>[a-zéû]+)\s*(?<PeriodStartDay>[0-9]+)[\s,]+[0-9\s]*to\s*(?<PeriodEndMonth>[a-zéû]+)\s*(?<PeriodEndDay>[0-9]+)[\s,]+(?<PeriodEndYear>[0-9]{4})", RegexOptions.IgnoreCase); //match = Regex.Match(source, @"<h3>Votre consommation internetdu (?<PeriodStartDay>[0-9]+) (?<PeriodStartMonth>[a-zéû]+) [0-9\s]*au (?<PeriodEndDay>[0-9]+) (?<PeriodEndMonth>[a-zéû]+) (?<PeriodEndYear>[0-9]{4})[^>]*", RegexOptions.IgnoreCase); if (!match.Success) { match = Regex.Match(source, @"<h3>Consommation\s*du\s*(?<PeriodStartDay>[0-9]+)\s*(?<PeriodStartMonth>[a-zéû]+)\s*[0-9\s]*au\s*(?<PeriodEndDay>[0-9]+)\s*(?<PeriodEndMonth>[a-zéû]+)\s*(?<PeriodEndYear>[0-9]{4})[^>]*", RegexOptions.IgnoreCase); } if (match.Success) { PeriodEnd = DateTime.ParseExact(String.Format("{0}-{1}-{2}", match.Groups["PeriodEndYear"].Value, MonthStringToInt(match.Groups["PeriodEndMonth"].Value), match.Groups["PeriodEndDay"].Value.PadLeft(2, '0')), "yyyy-MM-dd", CultureInfo.InvariantCulture); int year = PeriodEnd.Year; if (PeriodEnd.Month == 1 && MonthStringToInt(match.Groups["PeriodStartMonth"].Value) == "12") { year -= 1; } PeriodStart = DateTime.ParseExact(String.Format("{0}-{1}-{2}", year, MonthStringToInt(match.Groups["PeriodStartMonth"].Value), match.Groups["PeriodStartDay"].Value.PadLeft(2, '0')), "yyyy-MM-dd", CultureInfo.InvariantCulture); } else { throw new DecodeFailedException(DecodeFailedTypes.ShowPeriods, source); } // Périodes disponibles match = Regex.Match(source, "<select[^>]*>(?<options><option[^>]*>([^<]+)</option>)+</select>", RegexOptions.IgnoreCase); if (match.Success) { Match matchPeriods; int year; DateTime start; DateTime end; for (int i = 0; i < match.Groups[1].Captures.Count; i++) { // En cours (du 4 juillet au 3 août 2010) // En cours (du 4 décembre 2010 au 3 janvier 2011) //BillPeriods.Add(match.Groups[1].Captures[i].Value); //matchPeriods = Regex.Match(match.Groups[1].Captures[i].Value, @"(?<StartDay>\d+)\s+(?<StartMonth>janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre)[^\d]+(?<EndDay>\d+)\s+(?<EndMonth>janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre)\s+(?<EndYear>\d{4})", RegexOptions.IgnoreCase); //matchPeriods = Regex.Match(match.Groups[1].Captures[i].Value, @"(?<StartDay>\d+)\s+(?<StartMonth>janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre) [0-9\s]*[^\d]+(?<EndDay>\d+)\s+(?<EndMonth>janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre)\s+(?<EndYear>\d{4})", RegexOptions.IgnoreCase); matchPeriods = Regex.Match(match.Groups[1].Captures[i].Value, @"(?<StartMonth>[a-zéû]+)\s+(?<StartDay>\d+)[\s,]+[0-9\s]*to\s+(?<EndMonth>[a-zéû]+)\s+(?<EndDay>\d+)[\s,]+(?<EndYear>\d{4})", RegexOptions.IgnoreCase); if (!matchPeriods.Success) { matchPeriods = Regex.Match(match.Groups[1].Captures[i].Value, @"(?<StartDay>\d+)\s*(?<StartMonth>[a-zéû]+)\s*[0-9\s]*[^\d]+(?<EndDay>\d+)\s*(?<EndMonth>[a-zéû]+)\s*(?<EndYear>\d{4})", RegexOptions.IgnoreCase); } if (matchPeriods.Success) { try { end = DateTime.ParseExact(String.Format("{0}-{1}-{2}", matchPeriods.Groups["EndYear"].Value, MonthStringToInt(matchPeriods.Groups["EndMonth"].Value), matchPeriods.Groups["EndDay"].Value.PadLeft(2, '0')), "yyyy-MM-dd", CultureInfo.InvariantCulture); year = end.Year; if (end.Month == 1 && MonthStringToInt(matchPeriods.Groups["EndMonth"].Value) == "12") { year -= 1; } start = DateTime.ParseExact(String.Format("{0}-{1}-{2}", year, MonthStringToInt(matchPeriods.Groups["StartMonth"].Value), matchPeriods.Groups["StartDay"].Value.PadLeft(2, '0')), "yyyy-MM-dd", CultureInfo.InvariantCulture); BillPeriods.Add(new Period() { Start = start, End = end }); } catch { BillPeriods.Add(new Period() { Start = DateTime.MinValue, End = DateTime.MinValue.AddDays(1) }); } } } } else { throw new DecodeFailedException(DecodeFailedTypes.BillPeriods, source); } // Historique match = Regex.Match(source, @"<td[^>]*>(([a-zéû]+ [0-9]{1,2}) <br ?/?>)+</td><td[^>]*>(([\d,\.]+)<br ?/?>)+</td><td[^>]*>(([\d,\.]+)<br ?/?>)+</td><td[^>]*><table><?t?b?o?d?y?>?<tr><td[^>]*>(([\d,\.]+)<br ?/?>)+", RegexOptions.IgnoreCase); if (!match.Success) { match = Regex.Match(source, @"<td[^>]*>(([0-9]{1,2} [a-zéû]+) <br ?/?>)+</td><td[^>]*>(([0-9]+.{1}[0-9]{2})<br ?/?>)+</td><td[^>]*>(([0-9]+.{1}[0-9]{2})<br ?/?>)+</td><td[^>]*><table><?t?b?o?d?y?>?<tr><td[^>]*>(([0-9]+.{1}[0-9]{2})<br ?/?>)+", RegexOptions.IgnoreCase); } if (match.Success) { VideotronDailyUsage usage; DateTime daily; for (int i = 0; i < match.Groups[2].Captures.Count; i++) { daily = DateStrToDateTime(match.Groups[2].Captures[i].Value); usage = new VideotronDailyUsage(); usage.Day = daily; usage.Month = daily.Year.ToString() + daily.Month.ToString().PadLeft(2, '0'); if (Double.TryParse(match.Groups[4].Captures[i].Value, style, culture, out doubleValue)) { usage.Download = doubleValue; } if (Double.TryParse(match.Groups[6].Captures[i].Value, style, culture, out doubleValue)) { usage.Upload = doubleValue; } if (Double.TryParse(match.Groups[8].Captures[i].Value, style, culture, out doubleValue)) { usage.Total = doubleValue; } usage.Download = usage.Download * delta; usage.Upload = usage.Upload * delta; usage.Total = usage.Total * delta; usage.Period = new Period() { Start = PeriodStart, End = PeriodEnd }; DailyUsages.Add(usage); } } else { throw new DecodeFailedException(DecodeFailedTypes.History, source); } return(true); }
extern internal static void InternalTryParseUInt32(string str, string format, System.Globalization.NumberStyles style, out uint value);
extern internal static short InternalParseInt16(string str, string format, System.Globalization.NumberStyles style);