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
443d140f
Commit
443d140f
authored
Jul 28, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove publish `string content` api of ICapPublisher.
Publish<T> will support it.
parent
297cecfa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
111 deletions
+37
-111
CapPublisher.cs
src/DotNetCore.CAP.MySql/CapPublisher.cs
+18
-36
CapPublisher.cs
src/DotNetCore.CAP.SqlServer/CapPublisher.cs
+19
-35
ICapPublisher.cs
src/DotNetCore.CAP/ICapPublisher.cs
+0
-40
No files found.
src/DotNetCore.CAP.MySql/CapPublisher.cs
View file @
443d140f
...
@@ -38,25 +38,11 @@ namespace DotNetCore.CAP.MySql
...
@@ -38,25 +38,11 @@ namespace DotNetCore.CAP.MySql
}
}
}
}
public
void
Publish
(
string
name
,
string
content
)
{
CheckIsUsingEF
(
name
);
PublishCore
(
name
,
content
);
}
public
Task
PublishAsync
(
string
name
,
string
content
)
{
CheckIsUsingEF
(
name
);
return
PublishCoreAsync
(
name
,
content
);
}
public
void
Publish
<
T
>(
string
name
,
T
contentObj
)
public
void
Publish
<
T
>(
string
name
,
T
contentObj
)
{
{
CheckIsUsingEF
(
name
);
CheckIsUsingEF
(
name
);
var
content
=
Helper
.
ToJson
(
contentObj
);
var
content
=
Serialize
(
contentObj
);
PublishCore
(
name
,
content
);
PublishCore
(
name
,
content
);
}
}
...
@@ -65,36 +51,18 @@ namespace DotNetCore.CAP.MySql
...
@@ -65,36 +51,18 @@ namespace DotNetCore.CAP.MySql
{
{
CheckIsUsingEF
(
name
);
CheckIsUsingEF
(
name
);
var
content
=
Helper
.
ToJson
(
contentObj
);
var
content
=
Serialize
(
contentObj
);
return
PublishCoreAsync
(
name
,
content
);
return
PublishCoreAsync
(
name
,
content
);
}
}
public
void
Publish
(
string
name
,
string
content
,
IDbConnection
dbConnection
,
IDbTransaction
dbTransaction
=
null
)
{
CheckIsAdoNet
(
name
);
PrepareConnection
(
dbConnection
,
ref
dbTransaction
);
PublishWithTrans
(
name
,
content
,
dbConnection
,
dbTransaction
);
}
public
Task
PublishAsync
(
string
name
,
string
content
,
IDbConnection
dbConnection
,
IDbTransaction
dbTransaction
=
null
)
{
CheckIsAdoNet
(
name
);
PrepareConnection
(
dbConnection
,
ref
dbTransaction
);
return
PublishWithTransAsync
(
name
,
content
,
dbConnection
,
dbTransaction
);
}
public
void
Publish
<
T
>(
string
name
,
T
contentObj
,
IDbConnection
dbConnection
,
IDbTransaction
dbTransaction
=
null
)
public
void
Publish
<
T
>(
string
name
,
T
contentObj
,
IDbConnection
dbConnection
,
IDbTransaction
dbTransaction
=
null
)
{
{
CheckIsAdoNet
(
name
);
CheckIsAdoNet
(
name
);
PrepareConnection
(
dbConnection
,
ref
dbTransaction
);
PrepareConnection
(
dbConnection
,
ref
dbTransaction
);
var
content
=
Helper
.
ToJson
(
contentObj
);
var
content
=
Serialize
(
contentObj
);
PublishWithTrans
(
name
,
content
,
dbConnection
,
dbTransaction
);
PublishWithTrans
(
name
,
content
,
dbConnection
,
dbTransaction
);
}
}
...
@@ -105,13 +73,27 @@ namespace DotNetCore.CAP.MySql
...
@@ -105,13 +73,27 @@ namespace DotNetCore.CAP.MySql
PrepareConnection
(
dbConnection
,
ref
dbTransaction
);
PrepareConnection
(
dbConnection
,
ref
dbTransaction
);
var
content
=
Helper
.
ToJson
(
contentObj
);
var
content
=
Serialize
(
contentObj
);
return
PublishWithTransAsync
(
name
,
content
,
dbConnection
,
dbTransaction
);
return
PublishWithTransAsync
(
name
,
content
,
dbConnection
,
dbTransaction
);
}
}
#
region
private
methods
#
region
private
methods
private
string
Serialize
<
T
>(
T
obj
)
{
string
content
=
string
.
Empty
;
if
(
Helper
.
IsComplexType
(
typeof
(
T
)))
{
content
=
Helper
.
ToJson
(
obj
);
}
else
{
content
=
obj
?.
ToString
();
}
return
content
;
}
private
void
PrepareConnection
(
IDbConnection
dbConnection
,
ref
IDbTransaction
dbTransaction
)
private
void
PrepareConnection
(
IDbConnection
dbConnection
,
ref
IDbTransaction
dbTransaction
)
{
{
if
(
dbConnection
==
null
)
if
(
dbConnection
==
null
)
...
...
src/DotNetCore.CAP.SqlServer/CapPublisher.cs
View file @
443d140f
...
@@ -38,25 +38,11 @@ namespace DotNetCore.CAP.SqlServer
...
@@ -38,25 +38,11 @@ namespace DotNetCore.CAP.SqlServer
}
}
}
}
public
void
Publish
(
string
name
,
string
content
)
{
CheckIsUsingEF
(
name
);
PublishCore
(
name
,
content
);
}
public
Task
PublishAsync
(
string
name
,
string
content
)
{
CheckIsUsingEF
(
name
);
return
PublishCoreAsync
(
name
,
content
);
}
public
void
Publish
<
T
>(
string
name
,
T
contentObj
)
public
void
Publish
<
T
>(
string
name
,
T
contentObj
)
{
{
CheckIsUsingEF
(
name
);
CheckIsUsingEF
(
name
);
var
content
=
Helper
.
ToJson
(
contentObj
);
var
content
=
Serialize
(
contentObj
);
PublishCore
(
name
,
content
);
PublishCore
(
name
,
content
);
}
}
...
@@ -65,33 +51,17 @@ namespace DotNetCore.CAP.SqlServer
...
@@ -65,33 +51,17 @@ namespace DotNetCore.CAP.SqlServer
{
{
CheckIsUsingEF
(
name
);
CheckIsUsingEF
(
name
);
var
content
=
Helper
.
ToJson
(
contentObj
);
var
content
=
Serialize
(
contentObj
);
return
PublishCoreAsync
(
name
,
content
);
return
PublishCoreAsync
(
name
,
content
);
}
}
public
void
Publish
(
string
name
,
string
content
,
IDbConnection
dbConnection
,
IDbTransaction
dbTransaction
=
null
)
{
CheckIsAdoNet
(
name
);
PrepareConnection
(
dbConnection
,
ref
dbTransaction
);
PublishWithTrans
(
name
,
content
,
dbConnection
,
dbTransaction
);
}
public
Task
PublishAsync
(
string
name
,
string
content
,
IDbConnection
dbConnection
,
IDbTransaction
dbTransaction
=
null
)
{
CheckIsAdoNet
(
name
);
PrepareConnection
(
dbConnection
,
ref
dbTransaction
);
return
PublishWithTransAsync
(
name
,
content
,
dbConnection
,
dbTransaction
);
}
public
void
Publish
<
T
>(
string
name
,
T
contentObj
,
IDbConnection
dbConnection
,
IDbTransaction
dbTransaction
=
null
)
public
void
Publish
<
T
>(
string
name
,
T
contentObj
,
IDbConnection
dbConnection
,
IDbTransaction
dbTransaction
=
null
)
{
{
CheckIsAdoNet
(
name
);
CheckIsAdoNet
(
name
);
PrepareConnection
(
dbConnection
,
ref
dbTransaction
);
PrepareConnection
(
dbConnection
,
ref
dbTransaction
);
var
content
=
Helper
.
ToJson
(
contentObj
);
var
content
=
Serialize
(
contentObj
);
PublishWithTrans
(
name
,
content
,
dbConnection
,
dbTransaction
);
PublishWithTrans
(
name
,
content
,
dbConnection
,
dbTransaction
);
}
}
...
@@ -101,13 +71,27 @@ namespace DotNetCore.CAP.SqlServer
...
@@ -101,13 +71,27 @@ namespace DotNetCore.CAP.SqlServer
CheckIsAdoNet
(
name
);
CheckIsAdoNet
(
name
);
PrepareConnection
(
dbConnection
,
ref
dbTransaction
);
PrepareConnection
(
dbConnection
,
ref
dbTransaction
);
var
content
=
Helper
.
ToJson
(
contentObj
);
var
content
=
Serialize
(
contentObj
);
return
PublishWithTransAsync
(
name
,
content
,
dbConnection
,
dbTransaction
);
return
PublishWithTransAsync
(
name
,
content
,
dbConnection
,
dbTransaction
);
}
}
#
region
private
methods
#
region
private
methods
private
string
Serialize
<
T
>(
T
obj
)
{
string
content
=
string
.
Empty
;
if
(
Helper
.
IsComplexType
(
typeof
(
T
)))
{
content
=
Helper
.
ToJson
(
obj
);
}
else
{
content
=
obj
.
ToString
();
}
return
content
;
}
private
void
PrepareConnection
(
IDbConnection
dbConnection
,
ref
IDbTransaction
dbTransaction
)
private
void
PrepareConnection
(
IDbConnection
dbConnection
,
ref
IDbTransaction
dbTransaction
)
{
{
if
(
dbConnection
==
null
)
if
(
dbConnection
==
null
)
...
...
src/DotNetCore.CAP/ICapPublisher.cs
View file @
443d140f
...
@@ -8,28 +8,6 @@ namespace DotNetCore.CAP
...
@@ -8,28 +8,6 @@ namespace DotNetCore.CAP
/// </summary>
/// </summary>
public
interface
ICapPublisher
public
interface
ICapPublisher
{
{
/// <summary>
/// (EntityFramework) Asynchronous publish a message.
/// <para>
/// If you are using the EntityFramework, you need to configure the DbContextType first.
/// otherwise you need to use overloaded method with IDbConnection and IDbTransaction.
/// </para>
/// </summary>
/// <param name="name">the topic name or exchange router key.</param>
/// <param name="content">message body content.</param>
Task
PublishAsync
(
string
name
,
string
content
);
/// <summary>
/// (EntityFramework) Publish a message.
/// <para>
/// If you are using the EntityFramework, you need to configure the DbContextType first.
/// otherwise you need to use overloaded method with IDbConnection and IDbTransaction.
/// </para>
/// </summary>
/// <param name="name">the topic name or exchange router key.</param>
/// <param name="content">message body content.</param>
void
Publish
(
string
name
,
string
content
);
/// <summary>
/// <summary>
/// (EntityFramework) Asynchronous publish a object message.
/// (EntityFramework) Asynchronous publish a object message.
/// <para>
/// <para>
...
@@ -54,24 +32,6 @@ namespace DotNetCore.CAP
...
@@ -54,24 +32,6 @@ namespace DotNetCore.CAP
/// <param name="contentObj">message body content, that will be serialized of json.</param>
/// <param name="contentObj">message body content, that will be serialized of json.</param>
void
Publish
<
T
>(
string
name
,
T
contentObj
);
void
Publish
<
T
>(
string
name
,
T
contentObj
);
/// <summary>
/// (ado.net) Asynchronous publish a message.
/// </summary>
/// <param name="name">the topic name or exchange router key.</param>
/// <param name="content">message body content</param>
/// <param name="dbConnection">the connection of <see cref="IDbConnection"/></param>
/// <param name="dbTransaction">the transaction of <see cref="IDbTransaction"/></param>
Task
PublishAsync
(
string
name
,
string
content
,
IDbConnection
dbConnection
,
IDbTransaction
dbTransaction
=
null
);
/// <summary>
/// (ado.net) Publish a message.
/// </summary>
/// <param name="name">the topic name or exchange router key.</param>
/// <param name="content">message body content.</param>
/// <param name="dbConnection">the connection of <see cref="IDbConnection"/></param>
/// <param name="dbTransaction">the transaction of <see cref="IDbTransaction"/></param>
void
Publish
(
string
name
,
string
content
,
IDbConnection
dbConnection
,
IDbTransaction
dbTransaction
=
null
);
/// <summary>
/// <summary>
/// (ado.net) Asynchronous publish a object message.
/// (ado.net) Asynchronous publish a object message.
/// </summary>
/// </summary>
...
...
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