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
ccc41b72
Commit
ccc41b72
authored
Dec 15, 2016
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add config options fiels
parent
11102034
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
58 additions
and
7 deletions
+58
-7
BrokerOptions.cs
src/Cap.Consistency/BrokerOptions.cs
+13
-0
BuilderExtensions.cs
src/Cap.Consistency/BuilderExtensions.cs
+2
-2
Cap.Consistency.xproj
src/Cap.Consistency/Cap.Consistency.xproj
+2
-4
ConsistencyOptions.cs
src/Cap.Consistency/ConsistencyOptions.cs
+21
-0
ServiceCollectionExtensions.cs
src/Cap.Consistency/ServiceCollectionExtensions.cs
+19
-1
project.json
src/Cap.Consistency/project.json
+1
-0
No files found.
src/Cap.Consistency/BrokerOptions.cs
0 → 100644
View file @
ccc41b72
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Cap.Consistency
{
public
class
BrokerOptions
{
}
}
src/Cap.Consistency/BuilderExtensions.cs
View file @
ccc41b72
...
...
@@ -15,14 +15,14 @@ namespace Microsoft.AspNetCore.Builder
/// </summary>
/// <param name="app">The <see cref="IApplicationBuilder"/> instance this method extends.</param>
/// <returns>The <see cref="IApplicationBuilder"/> instance this method extends.</returns>
public
static
IApplicationBuilder
Use
KafkaConsistence
(
this
IApplicationBuilder
app
)
{
public
static
IApplicationBuilder
Use
Consistency
(
this
IApplicationBuilder
app
)
{
if
(
app
==
null
)
{
throw
new
ArgumentNullException
(
nameof
(
app
));
}
var
marker
=
app
.
ApplicationServices
.
GetService
<
ConsistencyMarkerService
>();
if
(
marker
==
null
)
{
throw
new
InvalidOperationException
(
"Add
KafkaConsistence
must be called on the service collection."
);
throw
new
InvalidOperationException
(
"Add
Consistency
must be called on the service collection."
);
}
return
app
;
...
...
src/Cap.Consistency/Cap.Consistency.xproj
View file @
ccc41b72
...
...
@@ -4,18 +4,16 @@
<VisualStudioVersion
Condition=
"'$(VisualStudioVersion)' == ''"
>
14.0
</VisualStudioVersion>
<VSToolsPath
Condition=
"'$(VSToolsPath)' == ''"
>
$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
</VSToolsPath>
</PropertyGroup>
<Import
Project=
"$(VSToolsPath)\DotNet\Microsoft.DotNet.Props"
Condition=
"'$(VSToolsPath)' != ''"
/>
<PropertyGroup
Label=
"Globals"
>
<ProjectGuid>
e8af8611-0ea4-4b19-bc48-87c57a87dc66
</ProjectGuid>
<RootNamespace>
KafkaConsistence
</RootNamespace>
<RootNamespace>
Cap.Consistency
</RootNamespace>
<BaseIntermediateOutputPath
Condition=
"'$(BaseIntermediateOutputPath)'=='' "
>
.\obj
</BaseIntermediateOutputPath>
<OutputPath
Condition=
"'$(OutputPath)'=='' "
>
.\bin\
</OutputPath>
<TargetFrameworkVersion>
v4.5
</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>
2.0
</SchemaVersion>
</PropertyGroup>
<Import
Project=
"$(VSToolsPath)\DotNet\Microsoft.DotNet.targets"
Condition=
"'$(VSToolsPath)' != ''"
/>
</Project>
</Project>
\ No newline at end of file
src/Cap.Consistency/ConsistencyOptions.cs
0 → 100644
View file @
ccc41b72
using
Cap.Consistency
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Microsoft.AspNetCore.Builder
{
/// <summary>
/// Represents all the options you can use to configure the system.
/// </summary>
public
class
ConsistencyOptions
{
/// <summary>
/// Gets or sets the <see cref="BrokerOptions"/> for the consistency system.
/// </summary>
public
BrokerOptions
Broker
{
get
;
set
;
}
=
new
BrokerOptions
();
}
}
src/Cap.Consistency/ServiceCollectionExtensions.cs
View file @
ccc41b72
using
Cap.Consistency
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.Extensions.DependencyInjection.Extensions
;
using
System
;
// ReSharper disable once CheckNamespace
namespace
Microsoft.Extensions.DependencyInjection
...
...
@@ -9,18 +11,34 @@ namespace Microsoft.Extensions.DependencyInjection
/// </summary>
public
static
class
ServiceCollectionExtensions
{
/// <summary>
/// Adds and configures the consistence services for the consitence.
/// </summary>
/// <param name="services">The services available in the application.</param>
/// <returns>An <see cref="
IServiceCollection
"/> for application services.</returns>
/// <returns>An <see cref="
ConsistencyBuilder
"/> for application services.</returns>
public
static
ConsistencyBuilder
AddConsistency
<
TMessage
>(
this
IServiceCollection
services
)
where
TMessage
:
class
{
return
services
.
AddConsistency
<
TMessage
>(
setupAction
:
null
);
}
/// <summary>
/// Adds and configures the consistence services for the consitence.
/// </summary>
/// <param name="services">The services available in the application.</param>
/// <param name="setupAction">An action to configure the <see cref="ConsistencyOptions"/>.</param>
/// <returns>An <see cref="ConsistencyBuilder"/> for application services.</returns>
public
static
ConsistencyBuilder
AddConsistency
<
TMessage
>(
this
IServiceCollection
services
,
Action
<
ConsistencyOptions
>
setupAction
)
where
TMessage
:
class
{
services
.
TryAddSingleton
<
ConsistencyMarkerService
>();
services
.
TryAddScoped
<
ConsistencyMessageManager
<
TMessage
>,
ConsistencyMessageManager
<
TMessage
>>();
if
(
setupAction
!=
null
)
{
services
.
Configure
(
setupAction
);
}
return
new
ConsistencyBuilder
(
typeof
(
TMessage
),
services
);
}
}
...
...
src/Cap.Consistency/project.json
View file @
ccc41b72
...
...
@@ -2,6 +2,7 @@
"version"
:
"1.0.0-*"
,
"dependencies"
:
{
"Microsoft.AspNetCore.Http.Abstractions"
:
"1.1.0-*"
,
"Microsoft.Extensions.Options"
:
"1.1.0-*"
,
"Microsoft.Extensions.DependencyInjection.Abstractions"
:
"1.1.0"
,
"Microsoft.Extensions.Logging.Abstractions"
:
"1.1.0-*"
,
"NETStandard.Library"
:
"1.6.1"
...
...
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