1、新增预任务生成帮助类
2、齐套配送接口参数调整
This commit is contained in:
@@ -24,6 +24,15 @@ namespace JNPF.Common.Extension
|
||||
setAction(instance, value);
|
||||
}
|
||||
|
||||
public static object GetPropertyValue<T>(this T obj, string propertyName)
|
||||
{
|
||||
if (!ProperyGet<T>.ValueFactories.TryGetValue(propertyName, out var getDateValue))
|
||||
{
|
||||
getDateValue = ProperyGet<T>.PropertyGetValue(propertyName);
|
||||
ProperyGet<T>.ValueFactories.Add(propertyName, getDateValue);
|
||||
}
|
||||
return getDateValue(obj);
|
||||
}
|
||||
/// <summary>
|
||||
/// Lambda表达式拼接
|
||||
/// </summary>
|
||||
@@ -144,4 +153,17 @@ namespace JNPF.Common.Extension
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ProperyGet<T> //where T : class, new()
|
||||
{
|
||||
public static Dictionary<string, Func<T, object>> ValueFactories = new Dictionary<string, Func<T, object>>(StringComparer.OrdinalIgnoreCase);
|
||||
public static Func<T, Object> PropertyGetValue(string name)
|
||||
{
|
||||
var parameterExp = Expression.Parameter(typeof(T), "entity");
|
||||
var propertyExp = Expression.Property(parameterExp, name);
|
||||
var castExp = Expression.Convert(propertyExp, typeof(object));
|
||||
var lambda = Expression.Lambda<Func<T, object>>(castExp, parameterExp);
|
||||
return lambda.Compile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user