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
e01ef4cb
Commit
e01ef4cb
authored
May 15, 2019
by
阿星Plus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🤩🤩🤩
parent
8455bd0b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
0 deletions
+88
-0
ICurrentUnitOfWorkProvider.cs
src/Plus/Domain/Uow/ICurrentUnitOfWorkProvider.cs
+14
-0
IUnitOfWorkFilterExecuter.cs
src/Plus/Domain/Uow/IUnitOfWorkFilterExecuter.cs
+11
-0
InnerUnitOfWorkCompleteHandle.cs
src/Plus/Domain/Uow/InnerUnitOfWorkCompleteHandle.cs
+63
-0
No files found.
src/Plus/Domain/Uow/ICurrentUnitOfWorkProvider.cs
0 → 100644
View file @
e01ef4cb
namespace
Plus.Domain.Uow
{
/// <summary>
/// Used to get/set current <see cref="IUnitOfWork"/>.
/// </summary>
public
interface
ICurrentUnitOfWorkProvider
{
/// <summary>
/// Gets/sets current <see cref="IUnitOfWork"/>.
/// Setting to null returns back to outer unit of work where possible.
/// </summary>
IUnitOfWork
Current
{
get
;
set
;
}
}
}
\ No newline at end of file
src/Plus/Domain/Uow/IUnitOfWorkFilterExecuter.cs
0 → 100644
View file @
e01ef4cb
namespace
Plus.Domain.Uow
{
public
interface
IUnitOfWorkFilterExecuter
{
void
ApplyDisableFilter
(
IUnitOfWork
unitOfWork
,
string
filterName
);
void
ApplyEnableFilter
(
IUnitOfWork
unitOfWork
,
string
filterName
);
void
ApplyFilterParameterValue
(
IUnitOfWork
unitOfWork
,
string
filterName
,
string
parameterName
,
object
value
);
}
}
\ No newline at end of file
src/Plus/Domain/Uow/InnerUnitOfWorkCompleteHandle.cs
0 → 100644
View file @
e01ef4cb
using
System
;
using
System.Runtime.InteropServices
;
using
System.Threading.Tasks
;
namespace
Plus.Domain.Uow
{
/// <summary>
/// This handle is used for innet unit of work scopes.
/// A inner unit of work scope actually uses outer unit of work scope
/// and has no effect on <see cref="IUnitOfWorkCompleteHandle.Complete"/> call.
/// But if it's not called, an exception is thrown at end of the UOW to rollback the UOW.
/// </summary>
internal
class
InnerUnitOfWorkCompleteHandle
:
IUnitOfWorkCompleteHandle
,
IDisposable
{
public
const
string
DidNotCallCompleteMethodExceptionMessage
=
"未调用完整方法的工作单元"
;
private
volatile
bool
_isCompleteCalled
;
private
volatile
bool
_isDisposed
;
public
void
Complete
()
{
_isCompleteCalled
=
true
;
}
public
Task
CompleteAsync
()
{
_isCompleteCalled
=
true
;
return
Task
.
FromResult
(
0
);
}
public
void
Dispose
()
{
if
(
_isDisposed
)
{
return
;
}
_isDisposed
=
true
;
if
(!
_isCompleteCalled
)
{
if
(
HasException
())
{
return
;
}
throw
new
PlusException
(
DidNotCallCompleteMethodExceptionMessage
);
}
}
private
static
bool
HasException
()
{
try
{
return
Marshal
.
GetExceptionCode
()
!=
0
;
}
catch
(
Exception
)
{
return
false
;
}
}
}
}
\ 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