File tree Expand file tree Collapse file tree 2 files changed +18
-20
lines changed
最后大项目代码/YouZack-VNext/Zack.Commons Expand file tree Collapse file tree 2 files changed +18
-20
lines changed Original file line number Diff line number Diff line change 11
11
namespace Zack . Commons ;
12
12
public static class ReflectionHelper
13
13
{
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
14
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
- }
15
+ /// <summary>
16
+ /// 据产品名称获取程序集
17
+ /// </summary>
18
+ /// <param name="productName"></param>
19
+ /// <returns></returns>
20
+ public static IEnumerable < Assembly > GetAssembliesByProductName ( string productName )
21
+ {
22
+ var asms = AppDomain . CurrentDomain . GetAssemblies ( ) ;
23
+ foreach ( var asm in asms )
24
+ {
25
+ var asmCompanyAttr = asm . GetCustomAttribute < AssemblyProductAttribute > ( ) ;
26
+ if ( asmCompanyAttr != null && asmCompanyAttr . Product == productName )
27
+ {
28
+ yield return asm ;
29
+ }
30
+ }
31
+ }
34
32
//是否是微软等的官方Assembly
35
33
private static bool IsSystemAssembly ( Assembly asm )
36
34
{
Original file line number Diff line number Diff line change 7
7
<Authors >Zack Yang</Authors >
8
8
<PackageProjectUrl >https://github.com/yangzhongke/NETBookMaterials</PackageProjectUrl >
9
9
<RepositoryUrl >https://github.com/yangzhongke/NETBookMaterials</RepositoryUrl >
10
- <Version >1.1.10 </Version >
10
+ <Version >1.1.11 </Version >
11
11
<LangVersion >10.0</LangVersion >
12
12
</PropertyGroup >
13
13
You can’t perform that action at this time.
0 commit comments