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
f768e62d
Commit
f768e62d
authored
Oct 19, 2017
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add custom content serializer extension to CapBuilder
parent
9edc31b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
6 deletions
+26
-6
CAP.Builder.cs
src/DotNetCore.CAP/CAP.Builder.cs
+26
-6
No files found.
src/DotNetCore.CAP/CAP.Builder.cs
View file @
f768e62d
using
System
;
using
DotNetCore.CAP.Abstractions
;
using
Microsoft.Extensions.DependencyInjection
;
namespace
DotNetCore.CAP
...
...
@@ -27,7 +28,7 @@ namespace DotNetCore.CAP
/// <summary>
/// Allows fine grained configuration of CAP services.
/// </summary>
public
class
CapBuilder
public
sealed
class
CapBuilder
{
public
CapBuilder
(
IServiceCollection
services
)
{
...
...
@@ -39,6 +40,26 @@ namespace DotNetCore.CAP
/// </summary>
public
IServiceCollection
Services
{
get
;
}
/// <summary>
/// Add an <see cref="ICapPublisher" />.
/// </summary>
/// <typeparam name="T">The type of the service.</typeparam>
public
CapBuilder
AddProducerService
<
T
>()
where
T
:
class
,
ICapPublisher
{
return
AddScoped
(
typeof
(
ICapPublisher
),
typeof
(
T
));
}
/// <summary>
/// Add a custom content serializer
/// </summary>
/// <typeparam name="T">The type of the service.</typeparam>
public
CapBuilder
AddContentSerializer
<
T
>()
where
T
:
class
,
IContentSerializer
{
return
AddSingleton
(
typeof
(
IContentSerializer
),
typeof
(
T
));
}
/// <summary>
/// Adds a scoped service of the type specified in serviceType with an implementation
/// </summary>
...
...
@@ -49,13 +70,12 @@ namespace DotNetCore.CAP
}
/// <summary>
/// Add
an <see cref="ICapPublisher" />.
/// Add
s a singleton service of the type specified in serviceType with an implementation
/// </summary>
/// <typeparam name="T">The type of the service.</typeparam>
public
virtual
CapBuilder
AddProducerService
<
T
>()
where
T
:
class
,
ICapPublisher
private
CapBuilder
AddSingleton
(
Type
serviceType
,
Type
concreteType
)
{
return
AddScoped
(
typeof
(
ICapPublisher
),
typeof
(
T
));
Services
.
AddSingleton
(
serviceType
,
concreteType
);
return
this
;
}
}
}
\ 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