temu客户端程序
This commit is contained in:
commit
4aaf264e89
694 files changed
+263780
No files matched your search
@@ -0,0 +1,35 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AllBase.Extension
|
||||
{
|
||||
public static class JTokenExtension
|
||||
{
|
||||
public static T ToValue<T>(this JToken token, T defValue = default(T))
|
||||
{
|
||||
string tempvalue = token.ToString();
|
||||
if (string.IsNullOrEmpty(tempvalue))
|
||||
return defValue;
|
||||
|
||||
Type type = typeof(T);
|
||||
var typeName = type.Name.ToLower();
|
||||
try
|
||||
{
|
||||
if (typeName == "string")
|
||||
return (T)(object)tempvalue;
|
||||
if (tempvalue is IConvertible)
|
||||
return (T)System.Convert.ChangeType(tempvalue, type);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
return defValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AllBase.Extension
|
||||
{
|
||||
public static class LinqExtension
|
||||
{
|
||||
public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
|
||||
{
|
||||
HashSet<TKey> seenKeys = new HashSet<TKey>();
|
||||
foreach (TSource element in source)
|
||||
{
|
||||
if (seenKeys.Add(keySelector(element)))
|
||||
{
|
||||
yield return element;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user