mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-21 02:58:06 +08:00
test: 优化类型匹配逻辑
This commit is contained in:
@@ -145,7 +145,7 @@ namespace SKIT.FlurlHttpClient.Wechat
|
|||||||
string json = File.ReadAllText(file);
|
string json = File.ReadAllText(file);
|
||||||
string name = Path.GetFileNameWithoutExtension(file).Split('.')[0];
|
string name = Path.GetFileNameWithoutExtension(file).Split('.')[0];
|
||||||
|
|
||||||
Type type = assembly.GetType($"{assembly.GetName().Name}.Models.{name}");
|
Type type = assembly.GetTypes().SingleOrDefault(e => e.FullName.StartsWith($"{assembly.GetName().Name}.Models.") && e.Name == name);
|
||||||
if (type == null)
|
if (type == null)
|
||||||
{
|
{
|
||||||
lstError.Add(new Exception($"类型 `{name}`不存在。"));
|
lstError.Add(new Exception($"类型 `{name}`不存在。"));
|
||||||
@@ -192,7 +192,7 @@ namespace SKIT.FlurlHttpClient.Wechat
|
|||||||
string json = File.ReadAllText(file);
|
string json = File.ReadAllText(file);
|
||||||
string name = Path.GetFileNameWithoutExtension(file).Split('.')[0];
|
string name = Path.GetFileNameWithoutExtension(file).Split('.')[0];
|
||||||
|
|
||||||
Type type = assembly.GetType($"{assembly.GetName().Name}.Events.{name}");
|
Type type = assembly.GetTypes().SingleOrDefault(e => e.FullName.StartsWith($"{assembly.GetName().Name}.Events.") && e.Name == name);
|
||||||
if (type == null)
|
if (type == null)
|
||||||
{
|
{
|
||||||
lstError.Add(new Exception($"类型 `{name}`不存在。"));
|
lstError.Add(new Exception($"类型 `{name}`不存在。"));
|
||||||
@@ -209,8 +209,8 @@ namespace SKIT.FlurlHttpClient.Wechat
|
|||||||
{
|
{
|
||||||
string xml = File.ReadAllText(file);
|
string xml = File.ReadAllText(file);
|
||||||
string name = Path.GetFileNameWithoutExtension(file).Split('.')[0];
|
string name = Path.GetFileNameWithoutExtension(file).Split('.')[0];
|
||||||
|
|
||||||
Type type = assembly.GetType($"{assembly.GetName().Name}.Events.{name}");
|
Type type = assembly.GetTypes().SingleOrDefault(e => e.FullName.StartsWith($"{assembly.GetName().Name}.Events.") && e.Name == name);
|
||||||
if (type == null)
|
if (type == null)
|
||||||
{
|
{
|
||||||
lstError.Add(new Exception($"类型 `{name}`不存在。"));
|
lstError.Add(new Exception($"类型 `{name}`不存在。"));
|
||||||
|
Reference in New Issue
Block a user