删除多余的Dictionary转Object
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"CorsAccessorSettings": {
|
"CorsAccessorSettings": {
|
||||||
"PolicyName": "JNPFCorsAccessor",
|
"PolicyName": "JNPFCorsAccessor",
|
||||||
"WithOrigins": [ "http://192.168.10.12:9230","http://localhost:8080", "http://localhost:9230" ],
|
//"WithOrigins": [ "http://localhost:9230" ],
|
||||||
"WithExposedHeaders": [ "access-token", "x-access-token", "Content-Disposition" ]
|
"WithExposedHeaders": [ "access-token", "x-access-token", "Content-Disposition" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,31 +57,4 @@ public static class DictionaryExtensions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dictionary<string, string[]> dicProperties = new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase);
|
|
||||||
/// <summary>
|
|
||||||
/// 字典转换成指定类型实例
|
|
||||||
/// added by ly on 20230524
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">转换的目标类型</typeparam>
|
|
||||||
/// <param name="dictionary">被转换的字典</param>
|
|
||||||
/// <returns>转换后的目标类型对象实例</returns>
|
|
||||||
public static T ToObject<T>(this Dictionary<String, Object> dictionary) where T : class, new()
|
|
||||||
{
|
|
||||||
var name = typeof(T).Name;
|
|
||||||
T instance = new();
|
|
||||||
if (!dicProperties.TryGetValue(name, out string[] properies))
|
|
||||||
{
|
|
||||||
properies = instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Select(p => p.Name).ToArray();
|
|
||||||
dicProperties[name] = properies;
|
|
||||||
}
|
|
||||||
foreach (var pn in properies)
|
|
||||||
{
|
|
||||||
if (dictionary.ContainsKey(pn))
|
|
||||||
{
|
|
||||||
instance.PropertySetValue(pn, dictionary[pn]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1354,8 +1354,8 @@ public class RunService : IRunService, ITransient
|
|||||||
{
|
{
|
||||||
if (!isSubFlow)
|
if (!isSubFlow)
|
||||||
{
|
{
|
||||||
// 新增,修改
|
// 新增,修改 modified by PhilPan 无需序列化
|
||||||
var dic = formData.ToObject<Dictionary<string, object>>();
|
var dic = formData; //.ToObject<Dictionary<string, object>>();
|
||||||
var dicHerader = new Dictionary<string, object>();
|
var dicHerader = new Dictionary<string, object>();
|
||||||
dicHerader.Add("JNPF_API", true);
|
dicHerader.Add("JNPF_API", true);
|
||||||
if (_userManager.ToKen != null && !_userManager.ToKen.Contains("::"))
|
if (_userManager.ToKen != null && !_userManager.ToKen.Contains("::"))
|
||||||
|
|||||||
Reference in New Issue
Block a user