Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
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
CAP
Commits
b298c943
Commit
b298c943
authored
Aug 14, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor of DI.
parent
af8c37cf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
34 deletions
+24
-34
CAP.MySqlCapOptionsExtension.cs
src/DotNetCore.CAP.MySql/CAP.MySqlCapOptionsExtension.cs
+10
-17
CAP.PostgreSqlCapOptionsExtension.cs
...tCore.CAP.PostgreSql/CAP.PostgreSqlCapOptionsExtension.cs
+10
-17
CAP.RabbitMQCapOptionsExtension.cs
...otNetCore.CAP.RabbitMQ/CAP.RabbitMQCapOptionsExtension.cs
+4
-0
No files found.
src/DotNetCore.CAP.MySql/CAP.MySqlCapOptionsExtension.cs
View file @
b298c943
...
...
@@ -28,24 +28,17 @@ namespace DotNetCore.CAP
if
(
mysqlOptions
.
DbContextType
!=
null
)
{
var
provider
=
TempBuildService
(
services
);
var
dbContextObj
=
provider
.
GetService
(
mysqlOptions
.
DbContextType
);
var
dbContext
=
(
DbContext
)
dbContextObj
;
mysqlOptions
.
ConnectionString
=
dbContext
.
Database
.
GetDbConnection
().
ConnectionString
;
services
.
AddSingleton
(
x
=>
{
var
dbContext
=
(
DbContext
)
x
.
GetService
(
mysqlOptions
.
DbContextType
);
mysqlOptions
.
ConnectionString
=
dbContext
.
Database
.
GetDbConnection
().
ConnectionString
;
return
mysqlOptions
;
});
}
else
{
services
.
AddSingleton
(
mysqlOptions
);
}
services
.
AddSingleton
(
mysqlOptions
);
}
#if NETSTANDARD1_6
private
IServiceProvider
TempBuildService
(
IServiceCollection
services
)
{
return
services
.
BuildServiceProvider
();
}
#else
private
ServiceProvider
TempBuildService
(
IServiceCollection
services
)
{
return
services
.
BuildServiceProvider
();
}
#endif
}
}
\ No newline at end of file
src/DotNetCore.CAP.PostgreSql/CAP.PostgreSqlCapOptionsExtension.cs
View file @
b298c943
...
...
@@ -28,24 +28,17 @@ namespace DotNetCore.CAP
if
(
postgreSqlOptions
.
DbContextType
!=
null
)
{
var
provider
=
TempBuildService
(
services
);
var
dbContextObj
=
provider
.
GetService
(
postgreSqlOptions
.
DbContextType
);
var
dbContext
=
(
DbContext
)
dbContextObj
;
postgreSqlOptions
.
ConnectionString
=
dbContext
.
Database
.
GetDbConnection
().
ConnectionString
;
services
.
AddSingleton
(
x
=>
{
var
dbContext
=
(
DbContext
)
x
.
GetService
(
postgreSqlOptions
.
DbContextType
);
postgreSqlOptions
.
ConnectionString
=
dbContext
.
Database
.
GetDbConnection
().
ConnectionString
;
return
postgreSqlOptions
;
});
}
else
{
services
.
AddSingleton
(
postgreSqlOptions
);
}
services
.
AddSingleton
(
postgreSqlOptions
);
}
#if NETSTANDARD1_6
private
IServiceProvider
TempBuildService
(
IServiceCollection
services
)
{
return
services
.
BuildServiceProvider
();
}
#else
private
ServiceProvider
TempBuildService
(
IServiceCollection
services
)
{
return
services
.
BuildServiceProvider
();
}
#endif
}
}
\ No newline at end of file
src/DotNetCore.CAP.RabbitMQ/CAP.RabbitMQCapOptionsExtension.cs
View file @
b298c943
...
...
@@ -21,6 +21,10 @@ namespace DotNetCore.CAP
services
.
AddSingleton
(
options
);
services
.
AddSingleton
<
IConsumerClientFactory
,
RabbitMQConsumerClientFactory
>();
services
.
AddSingleton
<
ConnectionPool
>();
services
.
AddScoped
(
x
=>
x
.
GetService
<
ConnectionPool
>().
Rent
());
services
.
AddTransient
<
IQueueExecutor
,
PublishQueueExecutor
>();
}
}
...
...
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