QueryStringFormat.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace Bowin.Common
  6. {
  7. public static class QueryStringFormat
  8. {
  9. public static string GetFormatStr(string AStr)
  10. {
  11. if ("" == AStr)
  12. return "";
  13. else
  14. {
  15. AStr = AStr.Replace("<", "〈");
  16. AStr = AStr.Replace(">", "〉");
  17. AStr = AStr.Replace("'", "’");
  18. return AStr;
  19. }
  20. }//格式化字符串
  21. public static string GetFormatStrbjq(string AStr)
  22. {
  23. if ("" == AStr)
  24. return "";
  25. else
  26. {
  27. AStr = AStr.Replace("'", "’");
  28. return AStr;
  29. }
  30. }//格式化字符串——用编辑器的-录入的时候
  31. public static string GetFormatStrmb(string AStr)
  32. {
  33. if ("" == AStr)
  34. return "";
  35. else
  36. {
  37. AStr = AStr.Replace("'", "’");
  38. AStr = AStr.Replace("\"", "");
  39. return AStr;
  40. }
  41. }//格式化字符串——用编辑器的-设置模版的时候
  42. public static string GetFormatStrbjq_show(string AStr)
  43. {
  44. if ("" == AStr)
  45. return "";
  46. else
  47. {
  48. AStr = AStr.Replace("’", "'");
  49. return AStr;
  50. }
  51. }//格式化字符串——用编辑器的-显示的时候
  52. public static string TbToLb(string AStr)
  53. {
  54. if ("" == AStr)
  55. return "";
  56. else
  57. {
  58. AStr = AStr.Replace("\n", "<br>");
  59. AStr = AStr.Replace(" ", "&nbsp;&nbsp;");
  60. return AStr;
  61. }
  62. }//从textbox的数据转换到lable中
  63. public static string GetQueryStringByPath(this Uri path, string key)
  64. {
  65. if (string.IsNullOrEmpty(path.Query))
  66. {
  67. return "";
  68. }
  69. string queryKey = key.ToLower();
  70. Dictionary<string, string> parameters = path.Query
  71. .TrimStart('?')
  72. .Split('&')
  73. .Select(x => (!string.IsNullOrEmpty(x)) ? x.Split('=').ToList() : new List<string> { "", "" })
  74. .ToDictionary(x => x[0].Trim().ToLower(), x => x[1].Trim());
  75. string value;
  76. if (!parameters.TryGetValue(queryKey, out value))
  77. {
  78. return "";
  79. }
  80. else
  81. {
  82. return value;
  83. }
  84. }
  85. }
  86. }