|
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | | -using System.Globalization; |
4 | 3 | using System.Linq; |
5 | 4 | using System.Reflection; |
6 | 5 |
|
@@ -43,31 +42,25 @@ internal static string ToQueryString(this object source, BindingFlags bindingAtt |
43 | 42 |
|
44 | 43 | if (value != null) |
45 | 44 | { |
46 | | - var type = value.GetType(); |
47 | | - |
48 | | - if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>)) |
| 45 | + if (value is List<string> stringValue) |
| 46 | + { |
| 47 | + values.Add(key + "=" + string.Join(",", stringValue)); |
| 48 | + } |
| 49 | + else if (value is List<int> intValue) |
| 50 | + { |
| 51 | + values.Add(key + "=" + string.Join(",", intValue)); |
| 52 | + } |
| 53 | + else if (value is List<TaskInfoStatus> taskInfoStatusValue) |
| 54 | + { |
| 55 | + values.Add(key + "=" + string.Join(",", taskInfoStatusValue.Select(x => x.ToString()))); |
| 56 | + } |
| 57 | + else if(value is List<TaskInfoType> taskInfoTypeValue) |
49 | 58 | { |
50 | | - var itemType = type.GetGenericArguments()[0]; |
51 | | - if (itemType == typeof(string)) |
52 | | - { |
53 | | - values.Add(key + "=" + string.Join(",", (List<string>)value)); |
54 | | - } |
55 | | - else if (itemType == typeof(int)) |
56 | | - { |
57 | | - values.Add(key + "=" + string.Join(",", (List<int>)value)); |
58 | | - } |
59 | | - else if (itemType == typeof(TaskInfoStatus)) |
60 | | - { |
61 | | - values.Add(key + "=" + string.Join(",", ((List<TaskInfoStatus>)value).Select(x => x.ToString()))); |
62 | | - } |
63 | | - else if (itemType == typeof(TaskInfoType)) |
64 | | - { |
65 | | - values.Add(key + "=" + string.Join(",", ((List<TaskInfoType>)value).Select(x => x.ToString()))); |
66 | | - } |
| 59 | + values.Add(key + "=" + string.Join(",", taskInfoTypeValue.Select(x => x.ToString()))); |
67 | 60 | } |
68 | | - else if (value is DateTime) |
| 61 | + else if (value is DateTime datetimeValue) |
69 | 62 | { |
70 | | - values.Add(key + "=" + Uri.EscapeDataString(((DateTime)value).ToString("yyyy-MM-dd'T'HH:mm:ss.fffzzz"))); |
| 63 | + values.Add(key + "=" + Uri.EscapeDataString(datetimeValue.ToString("yyyy-MM-dd'T'HH:mm:ss.fffzzz"))); |
71 | 64 | } |
72 | 65 | else |
73 | 66 | { |
|
0 commit comments