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
085df9d9
Commit
085df9d9
authored
May 17, 2019
by
阿星Plus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Services Dto
parent
9d3188ea
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
601 additions
and
4 deletions
+601
-4
PlusCrossCuttingConcerns.cs
src/Plus/Aspects/PlusCrossCuttingConcerns.cs
+1
-1
QueryableExtensions.cs
src/Plus/Linq/Extensions/QueryableExtensions.cs
+64
-0
IAsyncQueryableExecuter.cs
src/Plus/Linq/IAsyncQueryableExecuter.cs
+18
-0
NullAsyncQueryableExecuter.cs
src/Plus/Linq/NullAsyncQueryableExecuter.cs
+29
-0
NameValue.cs
src/Plus/NameValue.cs
+62
-0
ValidationInterceptorRegistrar.cs
...Validation/Interception/ValidationInterceptorRegistrar.cs
+1
-1
EntityDto.cs
src/Plus/Services/Dto/EntityDto.cs
+58
-0
IEntityDto.cs
src/Plus/Services/Dto/IEntityDto.cs
+22
-0
IHasLongTotalCount.cs
src/Plus/Services/Dto/IHasLongTotalCount.cs
+13
-0
IHasTotalCount.cs
src/Plus/Services/Dto/IHasTotalCount.cs
+13
-0
ILimitedResultRequest.cs
src/Plus/Services/Dto/ILimitedResultRequest.cs
+13
-0
IListResult.cs
src/Plus/Services/Dto/IListResult.cs
+16
-0
IPagedAndSortedResultRequest.cs
src/Plus/Services/Dto/IPagedAndSortedResultRequest.cs
+10
-0
IPagedResult.cs
src/Plus/Services/Dto/IPagedResult.cs
+11
-0
IPagedResultRequest.cs
src/Plus/Services/Dto/IPagedResultRequest.cs
+13
-0
ISortedResultRequest.cs
src/Plus/Services/Dto/ISortedResultRequest.cs
+21
-0
LimitedResultRequestDto.cs
src/Plus/Services/Dto/LimitedResultRequestDto.cs
+13
-0
ListResultDto.cs
src/Plus/Services/Dto/ListResultDto.cs
+40
-0
NameValueDto.cs
src/Plus/Services/Dto/NameValueDto.cs
+72
-0
NullableIdDto.cs
src/Plus/Services/Dto/NullableIdDto.cs
+44
-0
PagedAndSortedResultRequestDto.cs
src/Plus/Services/Dto/PagedAndSortedResultRequestDto.cs
+13
-0
PagedResultDto.cs
src/Plus/Services/Dto/PagedResultDto.cs
+37
-0
PagedResultRequestDto.cs
src/Plus/Services/Dto/PagedResultRequestDto.cs
+15
-0
IApplicationService.cs
src/Plus/Services/IApplicationService.cs
+1
-1
IAvoidDuplicateCrossCuttingConcerns.cs
src/Plus/Services/IAvoidDuplicateCrossCuttingConcerns.cs
+1
-1
No files found.
src/Plus/Aspects/PlusCrossCuttingConcerns.cs
View file @
085df9d9
using
Plus.Service
;
using
Plus.Service
s
;
using
System
;
using
System
;
namespace
Plus.Aspects
namespace
Plus.Aspects
...
...
src/Plus/Linq/Extensions/QueryableExtensions.cs
0 → 100644
View file @
085df9d9
using
Plus.Services.Dto
;
using
System
;
using
System.Linq
;
using
System.Linq.Expressions
;
namespace
Plus.Linq.Extensions
{
/// <summary>
/// Some useful extension methods for <see cref="IQueryable{T}"/>.
/// </summary>
public
static
class
QueryableExtensions
{
/// <summary>
/// Used for paging. Can be used as an alternative to Skip(...).Take(...) chaining.
/// </summary>
public
static
IQueryable
<
T
>
PageBy
<
T
>(
this
IQueryable
<
T
>
query
,
int
skipCount
,
int
maxResultCount
)
{
if
(
query
==
null
)
{
throw
new
ArgumentNullException
(
"query"
);
}
return
query
.
Skip
(
skipCount
).
Take
(
maxResultCount
);
}
/// <summary>
/// Used for paging with an <see cref="IPagedResultRequest"/> object.
/// </summary>
/// <param name="query">Queryable to apply paging</param>
/// <param name="pagedResultRequest">An object implements <see cref="IPagedResultRequest"/> interface</param>
public
static
IQueryable
<
T
>
PageBy
<
T
>(
this
IQueryable
<
T
>
query
,
IPagedResultRequest
pagedResultRequest
)
{
return
query
.
PageBy
(
pagedResultRequest
.
SkipCount
,
pagedResultRequest
.
MaxResultCount
);
}
/// <summary>
/// Filters a <see cref="IQueryable{T}"/> by given predicate if given condition is true.
/// </summary>
/// <param name="query">Queryable to apply filtering</param>
/// <param name="condition">A boolean value</param>
/// <param name="predicate">Predicate to filter the query</param>
/// <returns>Filtered or not filtered query based on <paramref name="condition"/></returns>
public
static
IQueryable
<
T
>
WhereIf
<
T
>(
this
IQueryable
<
T
>
query
,
bool
condition
,
Expression
<
Func
<
T
,
bool
>>
predicate
)
{
return
condition
?
query
.
Where
(
predicate
)
:
query
;
}
/// <summary>
/// Filters a <see cref="IQueryable{T}"/> by given predicate if given condition is true.
/// </summary>
/// <param name="query">Queryable to apply filtering</param>
/// <param name="condition">A boolean value</param>
/// <param name="predicate">Predicate to filter the query</param>
/// <returns>Filtered or not filtered query based on <paramref name="condition"/></returns>
public
static
IQueryable
<
T
>
WhereIf
<
T
>(
this
IQueryable
<
T
>
query
,
bool
condition
,
Expression
<
Func
<
T
,
int
,
bool
>>
predicate
)
{
return
condition
?
query
.
Where
(
predicate
)
:
query
;
}
}
}
\ No newline at end of file
src/Plus/Linq/IAsyncQueryableExecuter.cs
0 → 100644
View file @
085df9d9
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Plus.Linq
{
/// <summary>
/// IAsyncQueryableExecuter
/// </summary>
public
interface
IAsyncQueryableExecuter
{
Task
<
int
>
CountAsync
<
T
>(
IQueryable
<
T
>
queryable
);
Task
<
List
<
T
>>
ToListAsync
<
T
>(
IQueryable
<
T
>
queryable
);
Task
<
T
>
FirstOrDefaultAsync
<
T
>(
IQueryable
<
T
>
queryable
);
}
}
\ No newline at end of file
src/Plus/Linq/NullAsyncQueryableExecuter.cs
0 → 100644
View file @
085df9d9
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Plus.Linq
{
/// <summary>
/// NullAsyncQueryableExecuter
/// </summary>
public
class
NullAsyncQueryableExecuter
:
IAsyncQueryableExecuter
{
public
static
NullAsyncQueryableExecuter
Instance
{
get
;
}
=
new
NullAsyncQueryableExecuter
();
public
Task
<
int
>
CountAsync
<
T
>(
IQueryable
<
T
>
queryable
)
{
return
Task
.
FromResult
(
queryable
.
Count
());
}
public
Task
<
List
<
T
>>
ToListAsync
<
T
>(
IQueryable
<
T
>
queryable
)
{
return
Task
.
FromResult
(
queryable
.
ToList
());
}
public
Task
<
T
>
FirstOrDefaultAsync
<
T
>(
IQueryable
<
T
>
queryable
)
{
return
Task
.
FromResult
(
queryable
.
FirstOrDefault
());
}
}
}
\ No newline at end of file
src/Plus/NameValue.cs
0 → 100644
View file @
085df9d9
using
System
;
namespace
Plus
{
/// <summary>
/// Can be used to store Name/Value (or Key/Value) pairs.
/// </summary>
[
Serializable
]
public
class
NameValue
:
NameValue
<
string
>
{
/// <summary>
/// Creates a new <see cref="NameValue"/>.
/// </summary>
public
NameValue
()
{
}
/// <summary>
/// Creates a new <see cref="NameValue"/>.
/// </summary>
public
NameValue
(
string
name
,
string
value
)
{
Name
=
name
;
Value
=
value
;
}
}
/// <summary>
/// Can be used to store Name/Value (or Key/Value) pairs.
/// </summary>
[
Serializable
]
public
class
NameValue
<
T
>
{
/// <summary>
/// Name.
/// </summary>
public
string
Name
{
get
;
set
;
}
/// <summary>
/// Value.
/// </summary>
public
T
Value
{
get
;
set
;
}
/// <summary>
/// Creates a new <see cref="NameValue"/>.
/// </summary>
public
NameValue
()
{
}
/// <summary>
/// Creates a new <see cref="NameValue"/>.
/// </summary>
public
NameValue
(
string
name
,
T
value
)
{
Name
=
name
;
Value
=
value
;
}
}
}
\ No newline at end of file
src/Plus/Runtime/Validation/Interception/ValidationInterceptorRegistrar.cs
View file @
085df9d9
using
Castle.Core
;
using
Castle.Core
;
using
Castle.MicroKernel
;
using
Castle.MicroKernel
;
using
Plus.Dependency
;
using
Plus.Dependency
;
using
Plus.Service
;
using
Plus.Service
s
;
using
System.Reflection
;
using
System.Reflection
;
namespace
Plus.Runtime.Validation.Interception
namespace
Plus.Runtime.Validation.Interception
...
...
src/Plus/Services/Dto/EntityDto.cs
0 → 100644
View file @
085df9d9
using
System
;
namespace
Plus.Services.Dto
{
/// <summary>
/// A shortcut of <see cref="EntityDto{TPrimaryKey}"/> for most used primary key type (<see cref="int"/>).
/// </summary>
[
Serializable
]
public
class
EntityDto
:
EntityDto
<
int
>,
IEntityDto
{
/// <summary>
/// Creates a new <see cref="EntityDto"/> object.
/// </summary>
public
EntityDto
()
{
}
/// <summary>
/// Creates a new <see cref="EntityDto"/> object.
/// </summary>
/// <param name="id">Id of the entity</param>
public
EntityDto
(
int
id
)
:
base
(
id
)
{
}
}
/// <summary>
/// Implements common properties for entity based DTOs.
/// </summary>
/// <typeparam name="TPrimaryKey">Type of the primary key</typeparam>
[
Serializable
]
public
class
EntityDto
<
TPrimaryKey
>
:
IEntityDto
<
TPrimaryKey
>
{
/// <summary>
/// Id of the entity.
/// </summary>
public
TPrimaryKey
Id
{
get
;
set
;
}
/// <summary>
/// Creates a new <see cref="EntityDto{TPrimaryKey}"/> object.
/// </summary>
public
EntityDto
()
{
}
/// <summary>
/// Creates a new <see cref="EntityDto{TPrimaryKey}"/> object.
/// </summary>
/// <param name="id">Id of the entity</param>
public
EntityDto
(
TPrimaryKey
id
)
{
Id
=
id
;
}
}
}
\ No newline at end of file
src/Plus/Services/Dto/IEntityDto.cs
0 → 100644
View file @
085df9d9
namespace
Plus.Services.Dto
{
/// <summary>
/// A shortcut of <see cref="IEntityDto{TPrimaryKey}"/> for most used primary key type (<see cref="int"/>).
/// </summary>
public
interface
IEntityDto
:
IEntityDto
<
int
>
{
}
/// <summary>
/// Defines common properties for entity based DTOs.
/// </summary>
/// <typeparam name="TPrimaryKey"></typeparam>
public
interface
IEntityDto
<
TPrimaryKey
>
{
/// <summary>
/// Id of the entity.
/// </summary>
TPrimaryKey
Id
{
get
;
set
;
}
}
}
\ No newline at end of file
src/Plus/Services/Dto/IHasLongTotalCount.cs
0 → 100644
View file @
085df9d9
namespace
Plus.Services.Dto
{
/// <summary>
/// This interface is defined to standardize to set "Total Count of Items" to a DTO for long type.
/// </summary>
public
interface
IHasLongTotalCount
{
/// <summary>
/// Total count of Items.
/// </summary>
long
TotalCount
{
get
;
set
;
}
}
}
\ No newline at end of file
src/Plus/Services/Dto/IHasTotalCount.cs
0 → 100644
View file @
085df9d9
namespace
Plus.Services.Dto
{
/// <summary>
/// This interface is defined to standardize to set "Total Count of Items" to a DTO.
/// </summary>
public
interface
IHasTotalCount
{
/// <summary>
/// Total count of Items.
/// </summary>
int
TotalCount
{
get
;
set
;
}
}
}
\ No newline at end of file
src/Plus/Services/Dto/ILimitedResultRequest.cs
0 → 100644
View file @
085df9d9
namespace
Plus.Services.Dto
{
/// <summary>
/// This interface is defined to standardize to request a limited result.
/// </summary>
public
interface
ILimitedResultRequest
{
/// <summary>
/// Max expected result count.
/// </summary>
int
MaxResultCount
{
get
;
set
;
}
}
}
\ No newline at end of file
src/Plus/Services/Dto/IListResult.cs
0 → 100644
View file @
085df9d9
using
System.Collections.Generic
;
namespace
Plus.Services.Dto
{
/// <summary>
/// This interface is defined to standardize to return a list of items to clients.
/// </summary>
/// <typeparam name="T">Type of the items in the <see cref="Items"/> list</typeparam>
public
interface
IListResult
<
T
>
{
/// <summary>
/// List of items.
/// </summary>
IReadOnlyList
<
T
>
Items
{
get
;
set
;
}
}
}
\ No newline at end of file
src/Plus/Services/Dto/IPagedAndSortedResultRequest.cs
0 → 100644
View file @
085df9d9
namespace
Plus.Services.Dto
{
/// <summary>
/// This interface is defined to standardize to request a paged and sorted result.
/// </summary>
public
interface
IPagedAndSortedResultRequest
:
IPagedResultRequest
,
ISortedResultRequest
{
}
}
\ No newline at end of file
src/Plus/Services/Dto/IPagedResult.cs
0 → 100644
View file @
085df9d9
namespace
Plus.Services.Dto
{
/// <summary>
/// This interface is defined to standardize to return a page of items to clients.
/// </summary>
/// <typeparam name="T">Type of the items in the <see cref="IListResult{T}.Items"/> list</typeparam>
public
interface
IPagedResult
<
T
>
:
IListResult
<
T
>,
IHasTotalCount
{
}
}
\ No newline at end of file
src/Plus/Services/Dto/IPagedResultRequest.cs
0 → 100644
View file @
085df9d9
namespace
Plus.Services.Dto
{
/// <summary>
/// This interface is defined to standardize to request a paged result.
/// </summary>
public
interface
IPagedResultRequest
:
ILimitedResultRequest
{
/// <summary>
/// Skip count (beginning of the page).
/// </summary>
int
SkipCount
{
get
;
set
;
}
}
}
\ No newline at end of file
src/Plus/Services/Dto/ISortedResultRequest.cs
0 → 100644
View file @
085df9d9
namespace
Plus.Services.Dto
{
/// <summary>
/// This interface is defined to standardize to request a sorted result.
/// </summary>
public
interface
ISortedResultRequest
{
/// <summary>
/// Sorting information.
/// Should include sorting field and optionally a direction (ASC or DESC)
/// Can contain more than one field separated by comma (,).
/// </summary>
/// <example>
/// Examples:
/// "Name"
/// "Name DESC"
/// "Name ASC, Age DESC"
/// </example>
string
Sorting
{
get
;
set
;
}
}
}
\ No newline at end of file
src/Plus/Services/Dto/LimitedResultRequestDto.cs
0 → 100644
View file @
085df9d9
using
System.ComponentModel.DataAnnotations
;
namespace
Plus.Services.Dto
{
/// <summary>
/// Simply implements <see cref="ILimitedResultRequest"/>.
/// </summary>
public
class
LimitedResultRequestDto
:
ILimitedResultRequest
{
[
Range
(
1
,
int
.
MaxValue
)]
public
virtual
int
MaxResultCount
{
get
;
set
;
}
=
10
;
}
}
\ No newline at end of file
src/Plus/Services/Dto/ListResultDto.cs
0 → 100644
View file @
085df9d9
using
System
;
using
System.Collections.Generic
;
namespace
Plus.Services.Dto
{
/// <summary>
/// Implements <see cref="IListResult{T}"/>.
/// </summary>
/// <typeparam name="T">Type of the items in the <see cref="Items"/> list</typeparam>
[
Serializable
]
public
class
ListResultDto
<
T
>
:
IListResult
<
T
>
{
/// <summary>
/// List of items.
/// </summary>
public
IReadOnlyList
<
T
>
Items
{
get
{
return
_items
??
(
_items
=
new
List
<
T
>());
}
set
{
_items
=
value
;
}
}
private
IReadOnlyList
<
T
>
_items
;
/// <summary>
/// Creates a new <see cref="ListResultDto{T}"/> object.
/// </summary>
public
ListResultDto
()
{
}
/// <summary>
/// Creates a new <see cref="ListResultDto{T}"/> object.
/// </summary>
/// <param name="items">List of items</param>
public
ListResultDto
(
IReadOnlyList
<
T
>
items
)
{
Items
=
items
;
}
}
}
\ No newline at end of file
src/Plus/Services/Dto/NameValueDto.cs
0 → 100644
View file @
085df9d9
using
System
;
namespace
Plus.Services.Dto
{
/// <summary>
/// Can be used to send/receive Name/Value (or Key/Value) pairs.
/// </summary>
[
Serializable
]
public
class
NameValueDto
:
NameValueDto
<
string
>
{
/// <summary>
/// Creates a new <see cref="NameValueDto"/>.
/// </summary>
public
NameValueDto
()
{
}
/// <summary>
/// Creates a new <see cref="NameValueDto"/>.
/// </summary>
public
NameValueDto
(
string
name
,
string
value
)
:
base
(
name
,
value
)
{
}
/// <summary>
/// Creates a new <see cref="NameValueDto"/>.
/// </summary>
/// <param name="nameValue">A <see cref="NameValue"/> object to get it's name and value</param>
public
NameValueDto
(
NameValue
nameValue
)
:
this
(
nameValue
.
Name
,
nameValue
.
Value
)
{
}
}
/// <summary>
/// Can be used to send/receive Name/Value (or Key/Value) pairs.
/// </summary>
[
Serializable
]
public
class
NameValueDto
<
T
>
:
NameValue
<
T
>
{
/// <summary>
/// Creates a new <see cref="NameValueDto"/>.
/// </summary>
public
NameValueDto
()
{
}
/// <summary>
/// Creates a new <see cref="NameValueDto"/>.
/// </summary>
public
NameValueDto
(
string
name
,
T
value
)
:
base
(
name
,
value
)
{
}
/// <summary>
/// Creates a new <see cref="NameValueDto"/>.
/// </summary>
/// <param name="nameValue">A <see cref="NameValue"/> object to get it's name and value</param>
public
NameValueDto
(
NameValue
<
T
>
nameValue
)
:
this
(
nameValue
.
Name
,
nameValue
.
Value
)
{
}
}
}
\ No newline at end of file
src/Plus/Services/Dto/NullableIdDto.cs
0 → 100644
View file @
085df9d9
using
System
;
namespace
Plus.Services.Dto
{
/// <summary>
/// This DTO can be directly used (or inherited)
/// to pass an nullable Id value to an application service method.
/// </summary>
/// <typeparam name="TId">Type of the Id</typeparam>
[
Serializable
]
public
class
NullableIdDto
<
TId
>
where
TId
:
struct
{
public
TId
?
Id
{
get
;
set
;
}
public
NullableIdDto
()
{
}
public
NullableIdDto
(
TId
?
id
)
{
Id
=
id
;
}
}
/// <summary>
/// A shortcut of <see cref="NullableIdDto{TId}"/> for <see cref="int"/>.
/// </summary>
[
Serializable
]
public
class
NullableIdDto
:
NullableIdDto
<
int
>
{
public
NullableIdDto
()
{
}
public
NullableIdDto
(
int
?
id
)
:
base
(
id
)
{
}
}
}
\ No newline at end of file
src/Plus/Services/Dto/PagedAndSortedResultRequestDto.cs
0 → 100644
View file @
085df9d9
using
System
;
namespace
Plus.Services.Dto
{
/// <summary>
/// Simply implements <see cref="IPagedAndSortedResultRequest"/>.
/// </summary>
[
Serializable
]
public
class
PagedAndSortedResultRequestDto
:
PagedResultRequestDto
,
IPagedAndSortedResultRequest
{
public
virtual
string
Sorting
{
get
;
set
;
}
}
}
\ No newline at end of file
src/Plus/Services/Dto/PagedResultDto.cs
0 → 100644
View file @
085df9d9
using
System
;
using
System.Collections.Generic
;
namespace
Plus.Services.Dto
{
/// <summary>
/// Implements <see cref="IPagedResult{T}"/>.
/// </summary>
/// <typeparam name="T">Type of the items in the <see cref="ListResultDto{T}.Items"/> list</typeparam>
[
Serializable
]
public
class
PagedResultDto
<
T
>
:
ListResultDto
<
T
>,
IPagedResult
<
T
>
{
/// <summary>
/// Total count of Items.
/// </summary>
public
int
TotalCount
{
get
;
set
;
}
/// <summary>
/// Creates a new <see cref="PagedResultDto{T}"/> object.
/// </summary>
public
PagedResultDto
()
{
}
/// <summary>
/// Creates a new <see cref="PagedResultDto{T}"/> object.
/// </summary>
/// <param name="totalCount">Total count of Items</param>
/// <param name="items">List of items in current page</param>
public
PagedResultDto
(
int
totalCount
,
IReadOnlyList
<
T
>
items
)
:
base
(
items
)
{
TotalCount
=
totalCount
;
}
}
}
\ No newline at end of file
src/Plus/Services/Dto/PagedResultRequestDto.cs
0 → 100644
View file @
085df9d9
using
System
;
using
System.ComponentModel.DataAnnotations
;
namespace
Plus.Services.Dto
{
/// <summary>
/// Simply implements <see cref="IPagedResultRequest"/>.
/// </summary>
[
Serializable
]
public
class
PagedResultRequestDto
:
LimitedResultRequestDto
,
IPagedResultRequest
{
[
Range
(
0
,
int
.
MaxValue
)]
public
virtual
int
SkipCount
{
get
;
set
;
}
}
}
\ No newline at end of file
src/Plus/Service/IApplicationService.cs
→
src/Plus/Service
s
/IApplicationService.cs
View file @
085df9d9
using
Plus.Dependency
;
using
Plus.Dependency
;
namespace
Plus.Service
namespace
Plus.Service
s
{
{
/// <summary>
/// <summary>
/// IApplicationService
/// IApplicationService
...
...
src/Plus/Service/IAvoidDuplicateCrossCuttingConcerns.cs
→
src/Plus/Service
s
/IAvoidDuplicateCrossCuttingConcerns.cs
View file @
085df9d9
using
System.Collections.Generic
;
using
System.Collections.Generic
;
namespace
Plus.Service
namespace
Plus.Service
s
{
{
/// <summary>
/// <summary>
/// IAvoidDuplicateCrossCuttingConcerns
/// IAvoidDuplicateCrossCuttingConcerns
...
...
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