| | |
| | | namespace HStation.Service |
| | | namespace HStation.Service.Assets |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public class KeyWordHelper |
| | | { |
| | | public static List<string> ToList(string keyword) |
| | | { |
| | | if (string.IsNullOrEmpty(keyword)) |
| | | { |
| | | return new List<string>(); |
| | | } |
| | | |
| | | return keyword.Split(new string[1] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList(); |
| | | } |
| | | //分割字符 |
| | | private const char _split = ','; |
| | | |
| | | public static string ToString(List<string> KeyWord) |
| | | /// <summary> |
| | | /// 转化为字符串 |
| | | /// </summary> |
| | | public static string ToString(IEnumerable<string> list) |
| | | { |
| | | if (KeyWord == null || KeyWord.Count < 1) |
| | | if (list == null || list.Count() < 1) |
| | | { |
| | | return string.Empty; |
| | | } |
| | | |
| | | return string.Join(",", KeyWord); |
| | | return string.Join(_split.ToString(), list.Select(x => x.Trim())); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 转化为列表 |
| | | /// </summary> |
| | | public static List<string> ToList(string str) |
| | | { |
| | | if (string.IsNullOrEmpty(str)) |
| | | { |
| | | return new List<string>(); |
| | | } |
| | | return str.Split(_split, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToList(); |
| | | } |
| | | |
| | | } |
| | | } |