25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 

75 satır
3.3 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Reflection;
  6. using System.Text.RegularExpressions;
  7. using System.Threading.Tasks;
  8. using Models.Identity;
  9. namespace Services
  10. {
  11. public static class Statics
  12. {
  13. public const string TableClass = "table table-striped table-bordered border";
  14. public enum CultureType
  15. {
  16. En,
  17. Fa
  18. }
  19. public static CultureType Culture = CultureType.Fa;
  20. public static string LoginTokenKey = "SignIn";
  21. public static string RefreshTokenKey = "RefreshToken";
  22. public static string Agent = "";
  23. public static string FcmToken = "RefreshToken";
  24. public static CheckLoginResponse CurrentLoginInfo { get; set; }
  25. public static DateTime? LastCheck { set; get; }
  26. public static string BaseAddress = "https://api.senso.farm/";
  27. public static string UploadFolder=$"{BaseAddress}UploadedFiles";
  28. //linux:
  29. //public static string BaseAddress = "https://localhost:5001/";
  30. //windows:
  31. //public static string BaseAddress = "https://localhost:44331/";
  32. public static string ReplaceNewLineWithBr(this string text)
  33. {
  34. var result = Regex.Replace(text, @"\r\n?|\n", "<br/>");
  35. result = result.Replace("<br/><br/><br/>", "<br/>").Replace("<br/><br/>", "<br/>");
  36. return result;
  37. }
  38. public static CultureInfo GetPersianCulture()
  39. {
  40. var culture = new CultureInfo("fa-IR");
  41. DateTimeFormatInfo formatInfo = culture.DateTimeFormat;
  42. formatInfo.AbbreviatedDayNames = new[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
  43. formatInfo.DayNames = new[] { "یکشنبه", "دوشنبه", "سه شنبه", "چهار شنبه", "پنجشنبه", "جمعه", "شنبه" };
  44. var monthNames = new[]
  45. {
  46. "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن",
  47. "اسفند",
  48. "",
  49. };
  50. formatInfo.AbbreviatedMonthNames =
  51. formatInfo.MonthNames =
  52. formatInfo.MonthGenitiveNames = formatInfo.AbbreviatedMonthGenitiveNames = monthNames;
  53. formatInfo.AMDesignator = "ق.ظ";
  54. formatInfo.PMDesignator = "ب.ظ";
  55. formatInfo.ShortDatePattern = "yyyy/MM/dd";
  56. formatInfo.LongDatePattern = "dddd, dd MMMM,yyyy";
  57. formatInfo.FirstDayOfWeek = DayOfWeek.Saturday;
  58. System.Globalization.Calendar cal = new PersianCalendar();
  59. FieldInfo fieldInfo = culture.GetType().GetField("calendar", BindingFlags.NonPublic | BindingFlags.Instance);
  60. if (fieldInfo != null)
  61. fieldInfo.SetValue(culture, cal);
  62. FieldInfo info = formatInfo.GetType().GetField("calendar", BindingFlags.NonPublic | BindingFlags.Instance);
  63. if (info != null)
  64. info.SetValue(formatInfo, cal);
  65. culture.NumberFormat.NumberDecimalSeparator = "/";
  66. culture.NumberFormat.DigitSubstitution = DigitShapes.NativeNational;
  67. culture.NumberFormat.NumberNegativePattern = 0;
  68. return culture;
  69. }
  70. }
  71. }