Skip to content

Commit 44afe44

Browse files
authored
Merge pull request yangzhongke#8 from bocblca/main
Update ReflectionHelper.cs
2 parents 84d195f + b12b965 commit 44afe44

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

最后大项目代码/YouZack-VNext/Zack.Commons/ReflectionHelper.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,26 @@
1111
namespace Zack.Commons;
1212
public static class ReflectionHelper
1313
{
14+
//增加一个根据产品名称获取assembly的方法GetAssembliesByProductName
15+
public static List<Assembly>? GetAssembliesByProductName(string ProductName)
16+
{
17+
var asms = new List<Assembly>();
18+
var assm = AppDomain.CurrentDomain.GetAssemblies();
19+
foreach (var assa in assm)
20+
{
21+
22+
var asmCompanyAtt = assa.GetCustomAttribute<AssemblyProductAttribute>();
23+
if (asmCompanyAtt != null)
24+
{
25+
if (asmCompanyAtt.Product == ProductName) {
26+
asms.Add(assa);
27+
}
28+
}
29+
30+
}
31+
32+
return asms;
33+
}
1434
//是否是微软等的官方Assembly
1535
private static bool IsSystemAssembly(Assembly asm)
1636
{
@@ -202,4 +222,4 @@ public override int GetHashCode([DisallowNull] Assembly obj)
202222
return obj.GetName().FullName.GetHashCode();
203223
}
204224
}
205-
}
225+
}

0 commit comments

Comments
 (0)