From f6b6c12e0d692df7ef4dd3d308948f14a651b25b Mon Sep 17 00:00:00 2001 From: yuleyule66 Date: Sun, 25 Dec 2016 20:50:25 +0800 Subject: [PATCH] format code. --- .../ConsistencyServer.cs | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/Cap.Consistency.Server/ConsistencyServer.cs b/src/Cap.Consistency.Server/ConsistencyServer.cs index 71dab60..b68e7ba 100644 --- a/src/Cap.Consistency.Server/ConsistencyServer.cs +++ b/src/Cap.Consistency.Server/ConsistencyServer.cs @@ -18,16 +18,21 @@ namespace Cap.Consistency.Server private readonly ILogger _logger; private readonly IConsumer _consumer; - public ConsistencyServer(IOptions options, IApplicationLifetime applicationLifetime, ILoggerFactory loggerFactory) { - if (options == null) { + public ConsistencyServer(IOptions options, IApplicationLifetime applicationLifetime, + ILoggerFactory loggerFactory) + { + if (options == null) + { throw new ArgumentNullException(nameof(options)); } - if (applicationLifetime == null) { + if (applicationLifetime == null) + { throw new ArgumentNullException(nameof(applicationLifetime)); } - if (loggerFactory == null) { + if (loggerFactory == null) + { throw new ArgumentNullException(nameof(loggerFactory)); } @@ -41,8 +46,10 @@ namespace Cap.Consistency.Server public IFeatureCollection Features { get; set; } - public void Start(IHttpApplication application) { - if (_disposables != null) { + public void Start(IHttpApplication application) + { + if (_disposables != null) + { // The server has already started and/or has not been cleaned up yet throw new InvalidOperationException("Server has already started."); } @@ -55,23 +62,29 @@ namespace Cap.Consistency.Server var threadCount = Options.ThreadCount; - if (threadCount <= 0) { + if (threadCount <= 0) + { throw new ArgumentOutOfRangeException(nameof(threadCount), threadCount, "ThreadCount must be positive."); } - try { + try + { _consumer.Start(threadCount); } - catch (Exception ex) { + catch (Exception ex) + { throw ex; } } - public void Dispose() { - if (_disposables != null) { - while (_disposables.Count > 0) { + public void Dispose() + { + if (_disposables != null) + { + while (_disposables.Count > 0) + { _disposables.Pop().Dispose(); } _disposables = null;