Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
丁松杰
/
Pole
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
de898d8d
authored
Feb 20, 2020
by
dingsongjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化 程序集查找
parent
fb922525
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
14 deletions
src/Pole.Core/Utils/AssemblyHelper.cs
src/Pole.Core/Utils/AssemblyHelper.cs
View file @
de898d8d
...
...
@@ -10,22 +10,28 @@ namespace Pole.Core.Utils
{
public
class
AssemblyHelper
{
private
static
IList
<
Assembly
>
Assemblies
;
public
static
IList
<
Assembly
>
GetAssemblies
(
ILogger
logger
=
default
)
{
var
libs
=
DependencyContext
.
Default
.
CompileLibraries
.
Where
(
lib
=>
!
lib
.
Serviceable
);
return
libs
.
Select
(
lib
=>
{
try
{
return
AssemblyLoadContext
.
Default
.
LoadFromAssemblyName
(
new
AssemblyName
(
lib
.
Name
));
}
catch
(
Exception
ex
)
{
if
(
logger
!=
default
)
logger
.
LogWarning
(
ex
,
ex
.
Message
);
return
default
;
}
}).
Where
(
assembly
=>
assembly
!=
default
).
ToList
();
if
(
Assemblies
!=
null
)
{
return
Assemblies
;
}
var
libs
=
DependencyContext
.
Default
.
CompileLibraries
.
Where
(
lib
=>
!
lib
.
Serviceable
&&
!
lib
.
Name
.
StartsWith
(
"Microsoft"
)
&&
!
lib
.
Name
.
StartsWith
(
"System"
));
Assemblies
=
libs
.
Select
(
lib
=>
{
try
{
return
AssemblyLoadContext
.
Default
.
LoadFromAssemblyName
(
new
AssemblyName
(
lib
.
Name
));
}
catch
(
Exception
ex
)
{
if
(
logger
!=
default
)
logger
.
LogWarning
(
ex
,
ex
.
Message
);
return
default
;
}
}).
Where
(
assembly
=>
assembly
!=
default
).
ToList
();
return
Assemblies
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment