using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Bowin.Common { public static class QueryStringFormat { public static string GetFormatStr(string AStr) { if ("" == AStr) return ""; else { AStr = AStr.Replace("<", "〈"); AStr = AStr.Replace(">", "〉"); AStr = AStr.Replace("'", "’"); return AStr; } }//格式化字符串 public static string GetFormatStrbjq(string AStr) { if ("" == AStr) return ""; else { AStr = AStr.Replace("'", "’"); return AStr; } }//格式化字符串——用编辑器的-录入的时候 public static string GetFormatStrmb(string AStr) { if ("" == AStr) return ""; else { AStr = AStr.Replace("'", "’"); AStr = AStr.Replace("\"", ""); return AStr; } }//格式化字符串——用编辑器的-设置模版的时候 public static string GetFormatStrbjq_show(string AStr) { if ("" == AStr) return ""; else { AStr = AStr.Replace("’", "'"); return AStr; } }//格式化字符串——用编辑器的-显示的时候 public static string TbToLb(string AStr) { if ("" == AStr) return ""; else { AStr = AStr.Replace("\n", "
"); AStr = AStr.Replace(" ", "  "); return AStr; } }//从textbox的数据转换到lable中 public static string GetQueryStringByPath(this Uri path, string key) { if (string.IsNullOrEmpty(path.Query)) { return ""; } string queryKey = key.ToLower(); Dictionary parameters = path.Query .TrimStart('?') .Split('&') .Select(x => (!string.IsNullOrEmpty(x)) ? x.Split('=').ToList() : new List { "", "" }) .ToDictionary(x => x[0].Trim().ToLower(), x => x[1].Trim()); string value; if (!parameters.TryGetValue(queryKey, out value)) { return ""; } else { return value; } } } }