Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
EShop
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
EShop
Commits
a647720b
Commit
a647720b
authored
May 06, 2020
by
gdlcf88
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Completed PaymentServiceResolver
parent
37d907ed
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
2 deletions
+67
-2
FreePaymentServiceProvider.cs
...op.Payments.Domain/Payments/FreePaymentServiceProvider.cs
+1
-2
IPaymentServiceResolver.cs
...EShop.Payments.Domain/Payments/IPaymentServiceResolver.cs
+15
-0
PaymentServiceResolver.cs
....EShop.Payments.Domain/Payments/PaymentServiceResolver.cs
+51
-0
No files found.
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/FreePaymentServiceProvider.cs
→
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/
Payments/
FreePaymentServiceProvider.cs
View file @
a647720b
using
System.Collections.Generic
;
using
System.Threading.Tasks
;
using
EasyAbp.EShop.Payments.Payments
;
using
Microsoft.Extensions.DependencyInjection
;
using
Volo.Abp.DependencyInjection
;
namespace
EasyAbp.EShop.Payments
namespace
EasyAbp.EShop.Payments
.Payments
{
[
Dependency
(
ServiceLifetime
.
Transient
,
TryRegister
=
true
)]
public
class
FreePaymentServiceProvider
:
IPaymentServiceProvider
...
...
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/Payments/IPaymentServiceResolver.cs
0 → 100644
View file @
a647720b
using
System
;
using
System.Collections.Generic
;
using
System.Threading.Tasks
;
namespace
EasyAbp.EShop.Payments.Payments
{
public
interface
IPaymentServiceResolver
{
Task
<
bool
>
TryRegisterProviderAsync
(
string
paymentMethod
,
Type
providerType
);
Task
<
List
<
string
>>
GetPaymentMethodsAsync
();
Task
<
Type
>
GetProviderTypeOrDefaultAsync
(
string
paymentMethod
);
}
}
\ No newline at end of file
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/Payments/PaymentServiceResolver.cs
0 → 100644
View file @
a647720b
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Microsoft.Extensions.DependencyInjection
;
using
Volo.Abp.DependencyInjection
;
namespace
EasyAbp.EShop.Payments.Payments
{
public
class
PaymentServiceResolver
:
IPaymentServiceResolver
,
ISingletonDependency
{
protected
readonly
Dictionary
<
string
,
Type
>
Providers
=
new
Dictionary
<
string
,
Type
>();
private
readonly
IServiceProvider
_serviceProvider
;
public
PaymentServiceResolver
(
IServiceProvider
serviceProvider
)
{
_serviceProvider
=
serviceProvider
;
}
public
virtual
Task
<
bool
>
TryRegisterProviderAsync
(
string
paymentMethod
,
Type
providerType
)
{
if
(
Providers
.
ContainsKey
(
paymentMethod
))
{
return
Task
.
FromResult
(
false
);
}
using
(
var
scope
=
_serviceProvider
.
CreateScope
())
{
if
(
scope
.
ServiceProvider
.
GetService
(
providerType
)
==
null
)
{
return
Task
.
FromResult
(
false
);
}
}
Providers
.
Add
(
paymentMethod
,
providerType
);
return
Task
.
FromResult
(
true
);
}
public
virtual
Task
<
List
<
string
>>
GetPaymentMethodsAsync
()
{
return
Task
.
FromResult
(
Providers
.
Keys
.
ToList
());
}
public
virtual
Task
<
Type
>
GetProviderTypeOrDefaultAsync
(
string
paymentMethod
)
{
return
Task
.
FromResult
(
Providers
.
GetOrDefault
(
paymentMethod
));
}
}
}
\ 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