public double GetDoubleValue(MailTagTypes type) { switch (type) { case MailTagTypes.Upload: return(_account.Upload); case MailTagTypes.Download: return(_account.Download); case MailTagTypes.TotalCombinedRemaining: return(_account.CombinedRemaining); case MailTagTypes.TotalCombinedMax: return(_account.CombinedMaximum); case MailTagTypes.TotalCombined: return(_account.Combined); case MailTagTypes.SuggestDailyUsage: return(_account.SuggestCombined); case MailTagTypes.AverageCombined: return(_account.AverageCombined); case MailTagTypes.SuggestCombined: return(_account.SuggestCombined); case MailTagTypes.EstimateCombined: return(_account.EstimateCombined); case MailTagTypes.TheoryDailyCombined: return(_account.TheoryDailyCombined); case MailTagTypes.TheoryCombined: return(_account.TheoryCombined); case MailTagTypes.TheoryCombinedDifference: return(_account.TheoryCombinedVersusCombined); default: return(0.0); } }
private string FormatDouble(MailTagTypes type, string param) { double value = _factory.GetDoubleValue(type); SIUnitTypes unit = ProgramSettings.Instance.ShowUnitType; Match paramMatch = Regex.Match(param, METHOD_PARAM, RegexOptions.IgnoreCase); while (paramMatch.Success) { if (paramMatch.Groups["method"].Value.ToUpper() == "ROUND") { value = System.Math.Round(value, Int32.Parse(paramMatch.Groups["param"].Value)); } else if (paramMatch.Groups["method"].Value.ToUpper() == "UNIT") { switch (paramMatch.Groups["param"].Value.ToUpper()) { case "G": unit = SIUnitTypes.Go; break; case "M": unit = SIUnitTypes.Mo; break; case "K": unit = SIUnitTypes.ko; break; } } paramMatch = paramMatch.NextMatch(); } return(UnitsConverter.SIUnitToString(value, unit)); }
public bool IsDouble(MailTagTypes type) { switch (type) { case MailTagTypes.Upload: return(true); case MailTagTypes.Download: return(true); case MailTagTypes.TotalCombinedRemaining: return(true); case MailTagTypes.TotalCombinedMax: return(true); case MailTagTypes.TotalCombined: return(true); case MailTagTypes.SuggestDailyUsage: return(true); case MailTagTypes.AverageCombined: return(true); case MailTagTypes.SuggestCombined: return(true); case MailTagTypes.EstimateCombined: return(true); case MailTagTypes.TheoryDailyCombined: return(true); case MailTagTypes.TheoryCombined: return(true); case MailTagTypes.TheoryCombinedDifference: return(true); default: return(false); } }
public int GetIntValue(MailTagTypes type) { switch (type) { case MailTagTypes.DayRemaining: return _account.DayRemaining.Days; default: return 0; } }
public double GetCurrencyValue(MailTagTypes type) { switch (type) { case MailTagTypes.Overcharge: return _account.Overcharge; default: return 0.0; } }
public int GetIntValue(MailTagTypes type) { switch (type) { case MailTagTypes.DayRemaining: return(_account.DayRemaining.Days); default: return(0); } }
public double GetCurrencyValue(MailTagTypes type) { switch (type) { case MailTagTypes.Overcharge: return(_account.Overcharge); default: return(0.0); } }
public string GetStringValue(MailTagTypes type) { switch (type) { case MailTagTypes.Name: return(_account.DisplayName); case MailTagTypes.Username: return(_account.Username); default: return(String.Empty); } }
public DateTime GetDateTimeValue(MailTagTypes type) { switch (type) { case MailTagTypes.PeriodStart: return _account.PeriodStart; case MailTagTypes.PeriodEnd: return _account.PeriodEnd; case MailTagTypes.Now: return DateTime.Now; case MailTagTypes.LastUpdate: return _account.LastUpdate; default: return DateTime.MinValue; } }
public double GetPercentValue(MailTagTypes type) { switch (type) { case MailTagTypes.UploadPercent: return _account.UploadPercent; case MailTagTypes.DownloadPercent: return _account.DownloadPercent; case MailTagTypes.TotalCombinedPercent: return _account.CombinedPercent; case MailTagTypes.SuggestCombinedPercent: return _account.SuggestCombinedPercent; case MailTagTypes.TheoryDailyCombinedPercent: return _account.TheoryDailyCombinedPercent; default: return 0.0; } }
public DateTime GetDateTimeValue(MailTagTypes type) { switch (type) { case MailTagTypes.PeriodStart: return(_account.PeriodStart); case MailTagTypes.PeriodEnd: return(_account.PeriodEnd); case MailTagTypes.Now: return(DateTime.Now); case MailTagTypes.LastUpdate: return(_account.LastUpdate); default: return(DateTime.MinValue); } }
public bool IsDateTime(MailTagTypes type) { switch (type) { case MailTagTypes.PeriodStart: return(true); case MailTagTypes.PeriodEnd: return(true); case MailTagTypes.Now: return(true); case MailTagTypes.LastUpdate: return(true); default: return(false); } }
/// <summary> /// Converti un tag de format DateTime en une valeur string /// </summary> /// <param name="type">Le nom du tag</param> /// <param name="param">Les méthodes</param> /// <returns>La valeur à insérer dans le texte</returns> private string FormatDateTime(MailTagTypes type, string param) { Match paramMatch = Regex.Match(param, METHOD_PARAM, RegexOptions.IgnoreCase); while (paramMatch.Success) { if (paramMatch.Groups["method"].Value.ToUpper() == "FORMAT") { return(_factory.GetDateTimeValue(type).ToString(paramMatch.Groups["param"].Value)); } paramMatch = paramMatch.NextMatch(); } return(_factory.GetDateTimeValue(type).ToShortDateString()); }
/// <summary> /// Format une valeur en fonction des paramètres défini /// </summary> /// <param name="tag">Le tag trouvé dans le texte</param> /// <param name="param">Chaine de caractère représentant les fonctions à appliquer</param> /// <returns>Le nouvelle valeur</returns> private string Format(string tag, string param) { MailTagTypes type = _factory.GetType(tag); if (type != MailTagTypes.None) { try { // Si c'est une date if (_factory.IsDateTime(type)) { return(FormatDateTime(type, param)); } // Si c'est un double else if (_factory.IsDouble(type)) { return(FormatDouble(type, param)); } // Si c'est un pourcentage else if (_factory.IsPercent(type)) { return(FormatPercent(type, param)); } // Si c'est un integer else if (_factory.IsInt(type)) { return(_factory.GetIntValue(type).ToString()); } // Si c'est de la monnaie else if (_factory.IsCurrency(type)) { return(FormatCurrency(type, param)); } // Si c'est du texte else { return(_factory.GetStringValue(type)); } } catch (Exception formatExcep) { return(String.Format("({0})", formatExcep.Message)); } } return(string.Empty); }
public bool IsPercent(MailTagTypes type) { switch (type) { case MailTagTypes.UploadPercent: return(true); case MailTagTypes.DownloadPercent: return(true); case MailTagTypes.TotalCombinedPercent: return(true); case MailTagTypes.SuggestCombinedPercent: return(true); case MailTagTypes.TheoryDailyCombinedPercent: return(true); default: return(false); } }
public double GetPercentValue(MailTagTypes type) { switch (type) { case MailTagTypes.UploadPercent: return(_account.UploadPercent); case MailTagTypes.DownloadPercent: return(_account.DownloadPercent); case MailTagTypes.TotalCombinedPercent: return(_account.CombinedPercent); case MailTagTypes.SuggestCombinedPercent: return(_account.SuggestCombinedPercent); case MailTagTypes.TheoryDailyCombinedPercent: return(_account.TheoryDailyCombinedPercent); default: return(0.0); } }
public double GetDoubleValue(MailTagTypes type) { switch (type) { case MailTagTypes.Upload: return _account.Upload; case MailTagTypes.Download: return _account.Download; case MailTagTypes.TotalCombinedRemaining: return _account.CombinedRemaining; case MailTagTypes.TotalCombinedMax: return _account.CombinedMaximum; case MailTagTypes.TotalCombined: return _account.Combined; case MailTagTypes.SuggestDailyUsage: return _account.SuggestCombined; case MailTagTypes.AverageCombined: return _account.AverageCombined; case MailTagTypes.SuggestCombined: return _account.SuggestCombined; case MailTagTypes.EstimateCombined: return _account.EstimateCombined; case MailTagTypes.TheoryDailyCombined: return _account.TheoryDailyCombined; case MailTagTypes.TheoryCombined: return _account.TheoryCombined; case MailTagTypes.TheoryCombinedDifference: return _account.TheoryCombinedVersusCombined; default: return 0.0; } }
private string FormatPercent(MailTagTypes type, string param) { double value = _factory.GetPercentValue(type) * 100; int round = 2; Match paramMatch = Regex.Match(param, METHOD_PARAM, RegexOptions.IgnoreCase); while (paramMatch.Success) { if (paramMatch.Groups["method"].Value.ToUpper() == "ROUND") { round = Int32.Parse(paramMatch.Groups["param"].Value); } paramMatch = paramMatch.NextMatch(); } value = System.Math.Round(value, round); return(value.ToString()); }
public bool IsDouble(MailTagTypes type) { switch (type) { case MailTagTypes.Upload: return true; case MailTagTypes.Download: return true; case MailTagTypes.TotalCombinedRemaining: return true; case MailTagTypes.TotalCombinedMax: return true; case MailTagTypes.TotalCombined: return true; case MailTagTypes.SuggestDailyUsage: return true; case MailTagTypes.AverageCombined: return true; case MailTagTypes.SuggestCombined: return true; case MailTagTypes.EstimateCombined: return true; case MailTagTypes.TheoryDailyCombined: return true; case MailTagTypes.TheoryCombined: return true; case MailTagTypes.TheoryCombinedDifference: return true; default: return false; } }
public bool IsCurrency(MailTagTypes type) { return type == MailTagTypes.Overcharge; }
public bool IsPercent(MailTagTypes type) { switch (type) { case MailTagTypes.UploadPercent: return true; case MailTagTypes.DownloadPercent: return true; case MailTagTypes.TotalCombinedPercent: return true; case MailTagTypes.SuggestCombinedPercent: return true; case MailTagTypes.TheoryDailyCombinedPercent: return true; default: return false; } }
public bool IsInt(MailTagTypes type) { return type == MailTagTypes.DayRemaining; }
public bool IsCurrency(MailTagTypes type) { return(type == MailTagTypes.Overcharge); }
public string GetStringValue(MailTagTypes type) { switch (type) { case MailTagTypes.Name: return _account.DisplayName; case MailTagTypes.Username: return _account.Username; default: return String.Empty; } }
public bool IsDateTime(MailTagTypes type) { switch (type) { case MailTagTypes.PeriodStart: return true; case MailTagTypes.PeriodEnd: return true; case MailTagTypes.Now: return true; case MailTagTypes.LastUpdate: return true; default: return false; } }
private string FormatCurrency(MailTagTypes type, string param) { double value = _factory.GetCurrencyValue(type); return(value.ToString("C")); }
public bool IsInt(MailTagTypes type) { return(type == MailTagTypes.DayRemaining); }