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
3d55967b
Commit
3d55967b
authored
May 22, 2019
by
阿星Plus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
😭
😭
😭
😭
parent
13f40f08
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
124 additions
and
3 deletions
+124
-3
DefaultSettings.cs
src/Plus/Configuration/DefaultSettings.cs
+4
-1
DefaultConnectionStringResolver.cs
src/Plus/Domain/Uow/DefaultConnectionStringResolver.cs
+1
-1
EventPublisher.cs
src/Plus/Event/EventPublisher.cs
+52
-0
IConsumer.cs
src/Plus/Event/IConsumer.cs
+7
-0
IEventPublisher.cs
src/Plus/Event/IEventPublisher.cs
+9
-0
ISubscriptionService.cs
src/Plus/Event/ISubscriptionService.cs
+10
-0
SubscriptionService.cs
src/Plus/Event/SubscriptionService.cs
+13
-0
Plus.csproj
src/Plus/Plus.csproj
+1
-1
ApplicationServiceBase.cs
src/Plus/Services/ApplicationServiceBase.cs
+27
-0
No files found.
src/Plus/Configuration/DefaultSettings.cs
View file @
3d55967b
...
...
@@ -2,6 +2,9 @@
{
public
class
DefaultSettings
:
SettingsBase
{
public
string
DefaultNameOrConnectionString
=>
Config
[
"ConnectionStrings"
];
public
string
GetDefaultNameOrConnectionString
()
{
return
Config
[
"DefaultNameOrConnectionString"
];
}
}
}
\ No newline at end of file
src/Plus/Domain/Uow/DefaultConnectionStringResolver.cs
View file @
3d55967b
...
...
@@ -17,7 +17,7 @@ namespace Plus.Domain.Uow
public
virtual
string
GetNameOrConnectionString
(
ConnectionStringResolveArgs
args
)
{
string
defaultNameOrConnectionString
=
_configuration
.
DefaultSettings
.
DefaultNameOrConnectionString
;
string
defaultNameOrConnectionString
=
_configuration
.
DefaultSettings
.
GetDefaultNameOrConnectionString
()
;
if
(!
string
.
IsNullOrWhiteSpace
(
defaultNameOrConnectionString
))
{
return
defaultNameOrConnectionString
;
...
...
src/Plus/Event/EventPublisher.cs
0 → 100644
View file @
3d55967b
using
Castle.Core.Logging
;
using
Plus.Dependency
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
namespace
Plus.Event
{
public
class
EventPublisher
:
IEventPublisher
,
ITransientDependency
{
private
readonly
ISubscriptionService
_subscriptionService
;
public
ILogger
Logger
{
get
;
set
;
}
public
EventPublisher
(
ISubscriptionService
subscriptionService
)
{
_subscriptionService
=
subscriptionService
;
Logger
=
NullLogger
.
Instance
;
}
public
virtual
void
Publish
<
T
>(
T
eventMessage
)
{
IList
<
IConsumer
<
T
>>
subscriptions
=
_subscriptionService
.
GetSubscriptions
<
T
>();
subscriptions
.
ToList
().
ForEach
(
delegate
(
IConsumer
<
T
>
x
)
{
PublishToConsumer
(
x
,
eventMessage
);
});
}
protected
virtual
void
PublishToConsumer
<
T
>(
IConsumer
<
T
>
x
,
T
eventMessage
)
{
try
{
x
.
HandleEvent
(
eventMessage
);
}
catch
(
Exception
ex
)
{
try
{
Logger
.
Error
(
ex
.
Message
,
ex
);
}
catch
(
Exception
)
{
}
}
}
}
}
\ No newline at end of file
src/Plus/Event/IConsumer.cs
0 → 100644
View file @
3d55967b
namespace
Plus.Event
{
public
interface
IConsumer
<
T
>
{
void
HandleEvent
(
T
eventMessage
);
}
}
\ No newline at end of file
src/Plus/Event/IEventPublisher.cs
0 → 100644
View file @
3d55967b
using
Plus.Dependency
;
namespace
Plus.Event
{
public
interface
IEventPublisher
:
ITransientDependency
{
void
Publish
<
T
>(
T
eventMessage
);
}
}
\ No newline at end of file
src/Plus/Event/ISubscriptionService.cs
0 → 100644
View file @
3d55967b
using
Plus.Dependency
;
using
System.Collections.Generic
;
namespace
Plus.Event
{
public
interface
ISubscriptionService
:
ITransientDependency
{
IList
<
IConsumer
<
T
>>
GetSubscriptions
<
T
>();
}
}
\ No newline at end of file
src/Plus/Event/SubscriptionService.cs
0 → 100644
View file @
3d55967b
using
Plus.Dependency
;
using
System.Collections.Generic
;
namespace
Plus.Event
{
public
class
SubscriptionService
:
ISubscriptionService
,
ITransientDependency
{
public
IList
<
IConsumer
<
T
>>
GetSubscriptions
<
T
>()
{
return
PlusEngine
.
Instance
.
IocManager
.
ResolveAll
<
IConsumer
<
T
>>();
}
}
}
\ No newline at end of file
src/Plus/Plus.csproj
View file @
3d55967b
...
...
@@ -17,7 +17,7 @@
<PackageLicenseUrl>https://raw.githubusercontent.com/Meowv/.netcoreplus/master/LICENSE</PackageLicenseUrl>
<PackageTags>plus;.netcoreplus;</PackageTags>
<PackageReleaseNotes>Plus</PackageReleaseNotes>
<Version>1.0.1</Version>
<Version>1.0.1
.2
</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
...
...
src/Plus/Services/ApplicationServiceBase.cs
0 → 100644
View file @
3d55967b
using
Castle.Core.Logging
;
using
Plus.Dependency
;
using
Plus.Event
;
namespace
Plus.Services
{
public
abstract
class
ApplicationServiceBase
:
IApplicationService
,
ITransientDependency
{
public
ILogger
Logger
{
protected
get
;
set
;
}
public
IEventPublisher
EventPublisher
{
protected
get
;
set
;
}
protected
ApplicationServiceBase
()
{
Logger
=
NullLogger
.
Instance
;
EventPublisher
=
PlusEngine
.
Instance
.
Resolve
<
IEventPublisher
>();
}
}
}
\ 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