Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
netcoreplus
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
netcoreplus
Commits
a5a3bf6e
Commit
a5a3bf6e
authored
May 23, 2019
by
阿星Plus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善
parent
c57593e5
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
120 additions
and
16 deletions
+120
-16
DefaultSettings.cs
src/Plus/Configuration/DefaultSettings.cs
+1
-1
PlusStartupConfiguration.cs
src/Plus/Configuration/Startup/PlusStartupConfiguration.cs
+2
-1
PlusModuleInfo.cs
src/Plus/Modules/PlusModuleInfo.cs
+0
-10
PlusModuleManager.cs
src/Plus/Modules/PlusModuleManager.cs
+3
-3
Plus.csproj
src/Plus/Plus.csproj
+1
-1
ITypeFinder.cs
src/Plus/Reflection/ITypeFinder.cs
+10
-0
TypeFinder.cs
src/Plus/Reflection/TypeFinder.cs
+88
-0
IAmbientScopeProvider.cs
src/Plus/Runtime/IAmbientScopeProvider.cs
+15
-0
No files found.
src/Plus/Configuration/DefaultSettings.cs
View file @
a5a3bf6e
...
...
@@ -4,7 +4,7 @@
{
public
string
GetDefaultNameOrConnectionString
()
{
return
Config
[
"DefaultNameOrConnectionString"
];
return
Config
[
"DefaultNameOrConnectionString"
]
??
""
;
}
}
}
\ No newline at end of file
src/Plus/Configuration/Startup/PlusStartupConfiguration.cs
View file @
a5a3bf6e
...
...
@@ -23,9 +23,10 @@ namespace Plus.Configuration.Startup
public
DefaultSettings
DefaultSettings
{
get
;
private
set
;
}
public
PlusStartupConfiguration
(
IIocManager
iocManager
)
public
PlusStartupConfiguration
(
IIocManager
iocManager
,
DefaultSettings
settings
)
{
IocManager
=
iocManager
;
DefaultSettings
=
settings
;
}
public
void
Initialize
()
...
...
src/Plus/Modules/PlusModuleInfo.cs
View file @
a5a3bf6e
...
...
@@ -27,16 +27,6 @@ namespace Plus.Modules
Dependencies
=
new
List
<
PlusModuleInfo
>();
}
public
PlusModuleInfo
(
Type
type
,
PlusModule
instance
,
bool
isLoadedAsPlugIn
)
{
Type
=
type
;
Instance
=
instance
;
IsLoadedAsPlugIn
=
isLoadedAsPlugIn
;
Assembly
=
Type
.
GetTypeInfo
().
Assembly
;
Dependencies
=
new
List
<
PlusModuleInfo
>();
}
public
override
string
ToString
()
{
return
Type
.
AssemblyQualifiedName
??
Type
.
FullName
;
...
...
src/Plus/Modules/PlusModuleManager.cs
View file @
a5a3bf6e
...
...
@@ -67,7 +67,7 @@ namespace Plus.Modules
Logger
.
Debug
(
"找到 "
+
moduleTypes
.
Count
+
" 个模块."
);
RegisterModules
(
moduleTypes
);
CreateModules
(
moduleTypes
,
moduleTypes
);
CreateModules
(
moduleTypes
);
_modules
.
EnsureKernelModuleToBeFirst
();
_modules
.
EnsureStartupModuleToBeLast
();
...
...
@@ -82,7 +82,7 @@ namespace Plus.Modules
return
PlusModule
.
FindDependedModuleTypesRecursivelyIncludingGivenModule
(
_modules
.
StartupModuleType
);
}
private
void
CreateModules
(
ICollection
<
Type
>
moduleTypes
,
List
<
Type
>
plugInModuleTypes
)
private
void
CreateModules
(
ICollection
<
Type
>
moduleTypes
)
{
foreach
(
var
moduleType
in
moduleTypes
)
{
...
...
@@ -94,7 +94,7 @@ namespace Plus.Modules
moduleObject
.
IocManager
=
_iocManager
;
moduleObject
.
Configuration
=
_iocManager
.
Resolve
<
IPlusStartupConfiguration
>();
var
moduleInfo
=
new
PlusModuleInfo
(
moduleType
,
moduleObject
,
plugInModuleTypes
.
Contains
(
moduleType
)
);
var
moduleInfo
=
new
PlusModuleInfo
(
moduleType
,
moduleObject
);
_modules
.
Add
(
moduleInfo
);
...
...
src/Plus/Plus.csproj
View file @
a5a3bf6e
...
...
@@ -17,7 +17,7 @@
<PackageLicenseUrl>https://raw.githubusercontent.com/Meowv/.netcoreplus/master/LICENSE</PackageLicenseUrl>
<PackageTags>plus;.netcoreplus;</PackageTags>
<PackageReleaseNotes>Plus</PackageReleaseNotes>
<Version>1.0.3</Version>
<Version>1.0.3
.1
</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
...
...
src/Plus/Reflection/ITypeFinder.cs
View file @
a5a3bf6e
using
System
;
using
System.Collections.Generic
;
using
System.Reflection
;
namespace
Plus.Reflection
{
...
...
@@ -10,5 +12,13 @@ namespace Plus.Reflection
Type
[]
Find
(
Func
<
Type
,
bool
>
predicate
);
Type
[]
FindAll
();
IEnumerable
<
Type
>
FindClassesOfType
<
T
>(
bool
onlyConcreteClasses
=
true
);
IEnumerable
<
Type
>
FindClassesOfType
<
T
>(
IEnumerable
<
Assembly
>
assemblies
,
bool
onlyConcreteClasses
=
true
);
IEnumerable
<
Type
>
FindClassesOfType
(
Type
assignTypeFrom
,
bool
onlyConcreteClasses
=
true
);
IEnumerable
<
Type
>
FindClassesOfType
(
Type
assignTypeFrom
,
IEnumerable
<
Assembly
>
assemblies
,
bool
onlyConcreteClasses
=
true
);
}
}
\ No newline at end of file
src/Plus/Reflection/TypeFinder.cs
View file @
a5a3bf6e
...
...
@@ -85,5 +85,93 @@ namespace Plus.Reflection
return
allTypes
;
}
public
IEnumerable
<
Type
>
FindClassesOfType
<
T
>(
bool
onlyConcreteClasses
=
true
)
{
return
FindClassesOfType
(
typeof
(
T
),
onlyConcreteClasses
);
}
public
IEnumerable
<
Type
>
FindClassesOfType
(
Type
assignTypeFrom
,
bool
onlyConcreteClasses
=
true
)
{
return
FindClassesOfType
(
assignTypeFrom
,
_assemblyFinder
.
GetAllAssemblies
(),
onlyConcreteClasses
);
}
public
IEnumerable
<
Type
>
FindClassesOfType
<
T
>(
IEnumerable
<
Assembly
>
assemblies
,
bool
onlyConcreteClasses
=
true
)
{
return
FindClassesOfType
(
typeof
(
T
),
assemblies
,
onlyConcreteClasses
);
}
public
IEnumerable
<
Type
>
FindClassesOfType
(
Type
assignTypeFrom
,
IEnumerable
<
Assembly
>
assemblies
,
bool
onlyConcreteClasses
=
true
)
{
List
<
Type
>
list
=
new
List
<
Type
>();
try
{
foreach
(
Assembly
assembly
in
assemblies
)
{
Type
[]
array
=
null
;
try
{
array
=
assembly
.
GetTypes
();
}
catch
{
}
if
(
array
!=
null
)
{
Type
[]
array2
=
array
;
foreach
(
Type
type
in
array2
)
{
if
((
assignTypeFrom
.
IsAssignableFrom
(
type
)
||
(
assignTypeFrom
.
IsGenericTypeDefinition
&&
DoesTypeImplementOpenGeneric
(
type
,
assignTypeFrom
)))
&&
!
type
.
IsInterface
)
{
if
(
onlyConcreteClasses
)
{
if
(
type
.
IsClass
&&
!
type
.
IsAbstract
)
{
list
.
Add
(
type
);
}
}
else
{
list
.
Add
(
type
);
}
}
}
}
}
}
catch
(
ReflectionTypeLoadException
ex
)
{
string
text
=
string
.
Empty
;
Exception
[]
loaderExceptions
=
ex
.
LoaderExceptions
;
foreach
(
Exception
ex2
in
loaderExceptions
)
{
text
=
text
+
ex2
.
Message
+
Environment
.
NewLine
;
}
Exception
ex3
=
new
Exception
(
text
,
ex
);
throw
ex3
;
}
return
list
;
}
protected
virtual
bool
DoesTypeImplementOpenGeneric
(
Type
type
,
Type
openGeneric
)
{
try
{
Type
genericTypeDefinition
=
openGeneric
.
GetGenericTypeDefinition
();
Type
[]
array
=
type
.
FindInterfaces
((
Type
objType
,
object
objCriteria
)
=>
true
,
null
);
foreach
(
Type
type2
in
array
)
{
if
(
type2
.
IsGenericType
)
{
return
genericTypeDefinition
.
IsAssignableFrom
(
type2
.
GetGenericTypeDefinition
());
}
}
return
false
;
}
catch
{
return
false
;
}
}
}
}
\ No newline at end of file
src/Plus/Runtime/IAmbientScopeProvider.cs
0 → 100644
View file @
a5a3bf6e
using
System
;
namespace
Plus.Runtime
{
/// <summary>
/// IAmbientScopeProvider
/// </summary>
/// <typeparam name="T"></typeparam>
public
interface
IAmbientScopeProvider
<
T
>
{
T
GetValue
(
string
contextKey
);
IDisposable
BeginScope
(
string
contextKey
,
T
value
);
}
}
\ No newline at end of file
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