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
dccff2ac
Commit
dccff2ac
authored
Jun 07, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor
parent
f5635a5f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
78 deletions
+24
-78
ITopicRouteHandler.cs
src/Cap.Consistency/ITopicRouteHandler.cs
+12
-0
OperateResult.cs
src/Cap.Consistency/OperateResult.cs
+0
-78
TopicRouteContext.cs
src/Cap.Consistency/TopicRouteContext.cs
+12
-0
No files found.
src/Cap.Consistency/ITopicRouteHandler.cs
0 → 100644
View file @
dccff2ac
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Cap.Consistency
{
public
interface
ITopicRouteHandler
{
Task
RouteAsync
(
TopicRouteContext
context
);
}
}
src/Cap.Consistency/OperateResult.cs
deleted
100644 → 0
View file @
f5635a5f
using
System.Collections.Generic
;
using
System.Linq
;
namespace
Cap.Consistency
{
/// <summary>
/// Represents the result of an consistent message operation.
/// </summary>
public
class
OperateResult
{
// ReSharper disable once InconsistentNaming
private
static
readonly
OperateResult
_success
=
new
OperateResult
{
Succeeded
=
true
};
// ReSharper disable once FieldCanBeMadeReadOnly.Local
private
List
<
OperateError
>
_errors
=
new
List
<
OperateError
>();
/// <summary>
/// Flag indicating whether if the operation succeeded or not.
/// </summary>
public
bool
Succeeded
{
get
;
set
;
}
/// <summary>
/// An <see cref="IEnumerable{T}"/> of <see cref="OperateError"/>s containing an errors
/// that occurred during the operation.
/// </summary>
/// <value>An <see cref="IEnumerable{T}"/> of <see cref="OperateError"/>s.</value>
public
IEnumerable
<
OperateError
>
Errors
=>
_errors
;
/// <summary>
/// Returns an <see cref="OperateResult"/> indicating a successful identity operation.
/// </summary>
/// <returns>An <see cref="OperateResult"/> indicating a successful operation.</returns>
public
static
OperateResult
Success
=>
_success
;
/// <summary>
/// Creates an <see cref="OperateResult"/> indicating a failed operation, with a list of <paramref name="errors"/> if applicable.
/// </summary>
/// <param name="errors">An optional array of <see cref="OperateError"/>s which caused the operation to fail.</param>
/// <returns>An <see cref="OperateResult"/> indicating a failed operation, with a list of <paramref name="errors"/> if applicable.</returns>
public
static
OperateResult
Failed
(
params
OperateError
[]
errors
)
{
var
result
=
new
OperateResult
{
Succeeded
=
false
};
if
(
errors
!=
null
)
{
result
.
_errors
.
AddRange
(
errors
);
}
return
result
;
}
/// <summary>
/// Converts the value of the current <see cref="OperateResult"/> object to its equivalent string representation.
/// </summary>
/// <returns>A string representation of the current <see cref="OperateResult"/> object.</returns>
/// <remarks>
/// If the operation was successful the ToString() will return "Succeeded" otherwise it returned
/// "Failed : " followed by a comma delimited list of error codes from its <see cref="Errors"/> collection, if any.
/// </remarks>
public
override
string
ToString
()
{
return
Succeeded
?
"Succeeded"
:
string
.
Format
(
"{0} : {1}"
,
"Failed"
,
string
.
Join
(
","
,
Errors
.
Select
(
x
=>
x
.
Code
).
ToList
()));
}
}
/// <summary>
/// Encapsulates an error from the operate subsystem.
/// </summary>
public
class
OperateError
{
/// <summary>
/// Gets or sets ths code for this error.
/// </summary>
public
string
Code
{
get
;
set
;
}
/// <summary>
/// Gets or sets the description for this error.
/// </summary>
public
string
Description
{
get
;
set
;
}
}
}
\ No newline at end of file
src/Cap.Consistency/TopicRouteContext.cs
0 → 100644
View file @
dccff2ac
using
System
;
using
System.Collections.Generic
;
namespace
Cap.Consistency
{
public
class
TopicRouteContext
{
public
IServiceProvider
ServiceProvider
{
get
;
set
;
}
public
IList
<
ITopicRouteHandler
>
Routes
{
get
;
set
;
}
}
}
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