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
583f6c54
Commit
583f6c54
authored
Sep 05, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug #44
parent
2b6c54c4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
14 deletions
+35
-14
.gitignore
.gitignore
+4
-0
Program.cs
samples/Sample.RabbitMQ.SqlServer/Program.cs
+20
-11
CAP.SqlServerCapOptionsExtension.cs
...NetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs
+11
-3
No files found.
.gitignore
View file @
583f6c54
...
@@ -35,3 +35,7 @@ bin/
...
@@ -35,3 +35,7 @@ bin/
/.idea
/.idea
Properties
Properties
/pack.bat
/pack.bat
/src/DotNetCore.CAP/project.json
/src/DotNetCore.CAP/packages.config
/src/DotNetCore.CAP/DotNetCore.CAP.Net47.csproj
/NuGet.config
samples/Sample.RabbitMQ.SqlServer/Program.cs
View file @
583f6c54
using
System.IO
;
using
System.IO
;
using
Microsoft.AspNetCore
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.Configuration
;
...
@@ -7,22 +8,30 @@ namespace Sample.RabbitMQ.SqlServer
...
@@ -7,22 +8,30 @@ namespace Sample.RabbitMQ.SqlServer
{
{
public
class
Program
public
class
Program
{
{
//var config = new ConfigurationBuilder()
// .AddCommandLine(args)
// .AddEnvironmentVariables("ASPNETCORE_")
// .Build();
//var host = new WebHostBuilder()
// .UseConfiguration(config)
// .UseKestrel()
// .UseContentRoot(Directory.GetCurrentDirectory())
// .UseIISIntegration()
// .UseStartup<Startup>()
// .Build();
//host.Run();
public
static
void
Main
(
string
[]
args
)
public
static
void
Main
(
string
[]
args
)
{
{
var
config
=
new
ConfigurationBuilder
()
BuildWebHost
(
args
).
Run
();
.
AddCommandLine
(
args
)
}
.
AddEnvironmentVariables
(
"ASPNETCORE_"
)
.
Build
();
var
host
=
new
WebHostBuilder
()
public
static
IWebHost
BuildWebHost
(
string
[]
args
)
=>
.
UseConfiguration
(
config
)
WebHost
.
CreateDefaultBuilder
(
args
)
.
UseKestrel
()
.
UseContentRoot
(
Directory
.
GetCurrentDirectory
())
.
UseIISIntegration
()
.
UseStartup
<
Startup
>()
.
UseStartup
<
Startup
>()
.
Build
();
.
Build
();
host
.
Run
();
}
}
}
}
}
\ No newline at end of file
src/DotNetCore.CAP.SqlServer/CAP.SqlServerCapOptionsExtension.cs
View file @
583f6c54
...
@@ -23,7 +23,11 @@ namespace DotNetCore.CAP
...
@@ -23,7 +23,11 @@ namespace DotNetCore.CAP
services
.
AddScoped
<
ICapPublisher
,
CapPublisher
>();
services
.
AddScoped
<
ICapPublisher
,
CapPublisher
>();
services
.
AddTransient
<
ICallbackPublisher
,
CapPublisher
>();
services
.
AddTransient
<
ICallbackPublisher
,
CapPublisher
>();
services
.
AddTransient
<
IAdditionalProcessor
,
DefaultAdditionalProcessor
>();
services
.
AddTransient
<
IAdditionalProcessor
,
DefaultAdditionalProcessor
>();
AddSqlServerOptions
(
services
);
}
private
void
AddSqlServerOptions
(
IServiceCollection
services
)
{
var
sqlServerOptions
=
new
SqlServerOptions
();
var
sqlServerOptions
=
new
SqlServerOptions
();
_configure
(
sqlServerOptions
);
_configure
(
sqlServerOptions
);
...
@@ -32,9 +36,13 @@ namespace DotNetCore.CAP
...
@@ -32,9 +36,13 @@ namespace DotNetCore.CAP
{
{
services
.
AddSingleton
(
x
=>
services
.
AddSingleton
(
x
=>
{
{
var
dbContext
=
(
DbContext
)
x
.
GetService
(
sqlServerOptions
.
DbContextType
);
using
(
var
scope
=
x
.
CreateScope
())
sqlServerOptions
.
ConnectionString
=
dbContext
.
Database
.
GetDbConnection
().
ConnectionString
;
{
return
sqlServerOptions
;
var
provider
=
scope
.
ServiceProvider
;
var
dbContext
=
(
DbContext
)
provider
.
GetService
(
sqlServerOptions
.
DbContextType
);
sqlServerOptions
.
ConnectionString
=
dbContext
.
Database
.
GetDbConnection
().
ConnectionString
;
return
sqlServerOptions
;
}
});
});
}
}
else
else
...
...
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