From dccff2acbb6ccbc7171fa836a1744b38b9e56dc7 Mon Sep 17 00:00:00 2001 From: yangxiaodong Date: Wed, 7 Jun 2017 11:37:17 +0800 Subject: [PATCH] refactor --- src/Cap.Consistency/ITopicRouteHandler.cs | 12 ++++ src/Cap.Consistency/OperateResult.cs | 78 ----------------------- src/Cap.Consistency/TopicRouteContext.cs | 12 ++++ 3 files changed, 24 insertions(+), 78 deletions(-) create mode 100644 src/Cap.Consistency/ITopicRouteHandler.cs delete mode 100644 src/Cap.Consistency/OperateResult.cs create mode 100644 src/Cap.Consistency/TopicRouteContext.cs diff --git a/src/Cap.Consistency/ITopicRouteHandler.cs b/src/Cap.Consistency/ITopicRouteHandler.cs new file mode 100644 index 0000000..9faa945 --- /dev/null +++ b/src/Cap.Consistency/ITopicRouteHandler.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; + +namespace Cap.Consistency +{ + public interface ITopicRouteHandler + { + Task RouteAsync(TopicRouteContext context); + } +} diff --git a/src/Cap.Consistency/OperateResult.cs b/src/Cap.Consistency/OperateResult.cs deleted file mode 100644 index f51e3dd..0000000 --- a/src/Cap.Consistency/OperateResult.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -namespace Cap.Consistency -{ - /// - /// Represents the result of an consistent message operation. - /// - public class OperateResult - { - // ReSharper disable once InconsistentNaming - private static readonly OperateResult _success = new OperateResult { Succeeded = true }; - - // ReSharper disable once FieldCanBeMadeReadOnly.Local - private List _errors = new List(); - - /// - /// Flag indicating whether if the operation succeeded or not. - /// - public bool Succeeded { get; set; } - - /// - /// An of s containing an errors - /// that occurred during the operation. - /// - /// An of s. - public IEnumerable Errors => _errors; - - /// - /// Returns an indicating a successful identity operation. - /// - /// An indicating a successful operation. - public static OperateResult Success => _success; - - /// - /// Creates an indicating a failed operation, with a list of if applicable. - /// - /// An optional array of s which caused the operation to fail. - /// An indicating a failed operation, with a list of if applicable. - public static OperateResult Failed(params OperateError[] errors) { - var result = new OperateResult { Succeeded = false }; - if (errors != null) { - result._errors.AddRange(errors); - } - return result; - } - - /// - /// Converts the value of the current object to its equivalent string representation. - /// - /// A string representation of the current object. - /// - /// 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 collection, if any. - /// - public override string ToString() { - return Succeeded ? - "Succeeded" : - string.Format("{0} : {1}", "Failed", string.Join(",", Errors.Select(x => x.Code).ToList())); - } - } - - /// - /// Encapsulates an error from the operate subsystem. - /// - public class OperateError - { - /// - /// Gets or sets ths code for this error. - /// - public string Code { get; set; } - - /// - /// Gets or sets the description for this error. - /// - public string Description { get; set; } - } -} \ No newline at end of file diff --git a/src/Cap.Consistency/TopicRouteContext.cs b/src/Cap.Consistency/TopicRouteContext.cs new file mode 100644 index 0000000..08ee2d0 --- /dev/null +++ b/src/Cap.Consistency/TopicRouteContext.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; + +namespace Cap.Consistency +{ + public class TopicRouteContext + { + public IServiceProvider ServiceProvider { get; set; } + + public IList Routes { get; set; } + } +}