public bool IsLanguageSupported(CultureExpression cultureExpression) { if (cultureExpression.IsAllRegion) { return(supportedLanguages.FirstOrDefault(x => x.LanguageName == cultureExpression.LanguageName) != null); } return(supportedLanguages.FirstOrDefault(x => x.Language == cultureExpression.Language) != null); }
public string this[CultureExpression culture] { get { string result = CultureHelper.MatchCulture(notifications, culture, out CultureExpression matchedCulture); if (matchedCulture == null) { throw new Exception("language resource not found"); } return(result); } }
// 用于向申请者发送短信 // 通知创建申请成功 public Task SendCreationSuccessAsync(ReservationDetail reservation, CultureExpression culture) { if (reservation.PosterPhone != null && reservation.PosterName != null) { string phone = reservation.PosterPhone; string name = reservation.PosterName; int ID = reservation.Id; string message = "【北理网协】尊敬的" + name + "您好,您的电脑诊所预约已成功,预约号(标识ID)为" + ID + ",请耐心等待维修人员受理,若有变动请及时登录平台更改,谢谢。"; return(SendSMSAsync(phone, message)); } else { return(Task.CompletedTask); } }
public static bool TryParse(string language, out CultureExpression expression) { if (language.Length == 2) { expression = new CultureExpression() { RawString = language, LanguageName = language.ToLower(), RegionName = "", IsAllRegion = true }; return(true); } else if (language.Length == 4 && language.EndsWith("-*")) { expression = new CultureExpression() { RawString = language, LanguageName = language.Substring(0, 2).ToLower(), RegionName = "", IsAllRegion = true }; return(true); } else if (language.Length == 5 && language[2] == '-') { expression = new CultureExpression() { RawString = language, LanguageName = language.Substring(0, 2).ToLower(), RegionName = language.Substring(3, 2).ToUpper(), IsAllRegion = false }; return(true); } expression = null; return(false); }
public CultureOptions(string defaultLanguage, IEnumerable <string> supportedLanguages) { this.defaultLanguage = CultureExpression.Parse(defaultLanguage); this.supportedLanguages = supportedLanguages.Select(x => CultureExpression.Parse(x)).ToList(); }