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
9117dc93
Commit
9117dc93
authored
May 29, 2019
by
阿星Plus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mongodb setting
parent
9384d9b1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
2 deletions
+54
-2
AppSettings.cs
test/Plus.Core.Tests/Configuration/AppSettings.cs
+37
-1
MongoDbServerAddress.cs
test/Plus.Core.Tests/Configuration/MongoDbServerAddress.cs
+9
-0
appsettings.json
test/Plus.Web.Tests/appsettings.json
+8
-1
No files found.
test/Plus.Core.Tests/Configuration/AppSettings.cs
View file @
9117dc93
using
Microsoft.Extensions.Configuration
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
namespace
Plus.Core.Tests.Configuration
{
...
...
@@ -15,6 +17,40 @@ namespace Plus.Core.Tests.Configuration
_config
=
builder
.
Build
();
}
public
static
string
MySqlConnectionString
=>
_config
[
"ConnectionStrings:MySql"
];
private
static
IConfigurationSection
ConnectionStrings
=>
_config
.
GetSection
(
"ConnectionStrings"
);
public
static
string
MySqlConnectionString
=>
ConnectionStrings
[
"MySql"
];
public
static
class
MongoDb
{
private
static
IConfigurationSection
MongoDbSection
=>
_config
.
GetSection
(
"MongoDb"
);
public
static
string
ConnectionMode
=>
MongoDbSection
[
"ConnectionMode"
];
public
static
string
DatabaseName
=>
MongoDbSection
[
"DatabaseName"
];
public
static
string
Username
=>
MongoDbSection
[
"Username"
];
public
static
string
Password
=>
MongoDbSection
[
"Password"
];
public
static
IList
<
MongoDbServerAddress
>
Servers
{
get
{
var
arrays
=
MongoDbSection
.
GetSection
(
"Servers"
).
GetChildren
().
Select
(
x
=>
x
.
Value
).
ToArray
();
IList
<
MongoDbServerAddress
>
results
=
new
List
<
MongoDbServerAddress
>();
foreach
(
var
str
in
arrays
)
{
var
item
=
str
.
Replace
(
":"
,
":"
).
Split
(
':'
);
if
(
item
.
Length
==
2
)
{
results
.
Add
(
new
MongoDbServerAddress
()
{
Host
=
item
[
0
],
Port
=
item
[
1
].
ToInt
()
});
}
}
return
results
;
}
}
}
}
}
\ No newline at end of file
test/Plus.Core.Tests/Configuration/MongoDbServerAddress.cs
0 → 100644
View file @
9117dc93
namespace
Plus.Core.Tests.Configuration
{
public
class
MongoDbServerAddress
{
public
string
Host
{
get
;
set
;
}
public
int
Port
{
get
;
set
;
}
}
}
\ No newline at end of file
test/Plus.Web.Tests/appsettings.json
View file @
9117dc93
...
...
@@ -7,6 +7,13 @@
"AllowedHosts"
:
"*"
,
"DefaultNameOrConnectionString"
:
""
,
"ConnectionStrings"
:
{
"MySql"
:
"Server=localhost;User Id=root;Password=123456;Database=meowv_blog"
"MySql"
:
"Server=localhost;User Id=root;Password=123456;Database=meowv_blog"
,
"MongoDb"
:
{
"Servers"
:
[
"localhost:27019"
],
"ConnectionMode"
:
""
,
"DatabaseName"
:
""
,
"Username"
:
""
,
"Password"
:
""
}
}
}
\ 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