diff --git a/src/DotNetCore.CAP.EntityFrameworkCore/CAP.EFOptions.cs b/src/DotNetCore.CAP.EntityFrameworkCore/CAP.EFOptions.cs index 78ce66b..a742b2a 100644 --- a/src/DotNetCore.CAP.EntityFrameworkCore/CAP.EFOptions.cs +++ b/src/DotNetCore.CAP.EntityFrameworkCore/CAP.EFOptions.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace DotNetCore.CAP { @@ -29,4 +27,4 @@ namespace DotNetCore.CAP public Type DbContextType { get; internal set; } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP.EntityFrameworkCore/CAP.SqlServerCapOptionsExtension.cs b/src/DotNetCore.CAP.EntityFrameworkCore/CAP.SqlServerCapOptionsExtension.cs index 0d0cda4..8f60f34 100644 --- a/src/DotNetCore.CAP.EntityFrameworkCore/CAP.SqlServerCapOptionsExtension.cs +++ b/src/DotNetCore.CAP.EntityFrameworkCore/CAP.SqlServerCapOptionsExtension.cs @@ -28,4 +28,4 @@ namespace DotNetCore.CAP services.AddSingleton(sqlServerOptions); } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP.EntityFrameworkCore/CAP.SqlServerOptions.cs b/src/DotNetCore.CAP.EntityFrameworkCore/CAP.SqlServerOptions.cs index 817e045..40a2d4f 100644 --- a/src/DotNetCore.CAP.EntityFrameworkCore/CAP.SqlServerOptions.cs +++ b/src/DotNetCore.CAP.EntityFrameworkCore/CAP.SqlServerOptions.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using DotNetCore.CAP.EntityFrameworkCore; - -namespace DotNetCore.CAP +namespace DotNetCore.CAP { public class SqlServerOptions : EFOptions { @@ -11,6 +6,5 @@ namespace DotNetCore.CAP /// Gets or sets the database's connection string that will be used to store database entities. /// public string ConnectionString { get; set; } //= "Server=DESKTOP-M9R8T31;Initial Catalog=Test;User Id=sa;Password=P@ssw0rd;MultipleActiveResultSets=True"; - } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP.EntityFrameworkCore/CapPublisher.cs b/src/DotNetCore.CAP.EntityFrameworkCore/CapPublisher.cs index 8e1e65a..13a8700 100644 --- a/src/DotNetCore.CAP.EntityFrameworkCore/CapPublisher.cs +++ b/src/DotNetCore.CAP.EntityFrameworkCore/CapPublisher.cs @@ -93,4 +93,4 @@ namespace DotNetCore.CAP.EntityFrameworkCore PublishQueuer.PulseEvent.Set(); } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP.EntityFrameworkCore/FetchedMessage.cs b/src/DotNetCore.CAP.EntityFrameworkCore/FetchedMessage.cs index 5e9fad2..13dbc0f 100644 --- a/src/DotNetCore.CAP.EntityFrameworkCore/FetchedMessage.cs +++ b/src/DotNetCore.CAP.EntityFrameworkCore/FetchedMessage.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using DotNetCore.CAP.Models; +using DotNetCore.CAP.Models; namespace DotNetCore.CAP.EntityFrameworkCore { @@ -11,4 +8,4 @@ namespace DotNetCore.CAP.EntityFrameworkCore public MessageType MessageType { get; set; } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP.EntityFrameworkCore/IAdditionalProcessor.Default.cs b/src/DotNetCore.CAP.EntityFrameworkCore/IAdditionalProcessor.Default.cs index fe31d0a..89126ac 100644 --- a/src/DotNetCore.CAP.EntityFrameworkCore/IAdditionalProcessor.Default.cs +++ b/src/DotNetCore.CAP.EntityFrameworkCore/IAdditionalProcessor.Default.cs @@ -1,11 +1,8 @@ using System; -using System.Collections.Generic; using System.Data.SqlClient; -using System.Text; using System.Threading.Tasks; using Dapper; using DotNetCore.CAP.Processor; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; namespace DotNetCore.CAP.EntityFrameworkCore @@ -44,14 +41,14 @@ namespace DotNetCore.CAP.EntityFrameworkCore var removedCount = 0; do { - using(var connection = new SqlConnection(_options.ConnectionString)) + using (var connection = new SqlConnection(_options.ConnectionString)) { removedCount = await connection.ExecuteAsync($@" DELETE TOP (@count) FROM [{_options.Schema}].[{table}] WITH (readpast) WHERE ExpiresAt < @now;", new { now = DateTime.Now, count = MaxBatch }); } - + if (removedCount != 0) { await context.WaitAsync(_delay); @@ -63,4 +60,4 @@ WHERE ExpiresAt < @now;", new { now = DateTime.Now, count = MaxBatch }); await context.WaitAsync(_waitingInterval); } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP.EntityFrameworkCore/SqlServerFetchedMessage.cs b/src/DotNetCore.CAP.EntityFrameworkCore/SqlServerFetchedMessage.cs index 0a0004e..e93167d 100644 --- a/src/DotNetCore.CAP.EntityFrameworkCore/SqlServerFetchedMessage.cs +++ b/src/DotNetCore.CAP.EntityFrameworkCore/SqlServerFetchedMessage.cs @@ -1,11 +1,8 @@ using System; -using System.Collections.Generic; using System.Data; -using System.Text; using System.Threading; using Dapper; using DotNetCore.CAP.Models; -using Microsoft.EntityFrameworkCore.Storage; namespace DotNetCore.CAP.EntityFrameworkCore { @@ -73,4 +70,4 @@ namespace DotNetCore.CAP.EntityFrameworkCore } } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP.EntityFrameworkCore/SqlServerStorage.cs b/src/DotNetCore.CAP.EntityFrameworkCore/SqlServerStorage.cs index 4d29987..b5b73bb 100644 --- a/src/DotNetCore.CAP.EntityFrameworkCore/SqlServerStorage.cs +++ b/src/DotNetCore.CAP.EntityFrameworkCore/SqlServerStorage.cs @@ -43,7 +43,6 @@ namespace DotNetCore.CAP.EntityFrameworkCore protected virtual string CreateDbTablesScript(string schema) { - var batchSQL = $@" IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = '{schema}') @@ -72,7 +71,7 @@ CREATE TABLE [{schema}].[Received]( [Added] [datetime2](7) NOT NULL, [ExpiresAt] [datetime2](7) NULL, [StatusName] [nvarchar](50) NOT NULL, - CONSTRAINT [PK_{schema}.Received] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_{schema}.Received] PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] @@ -90,7 +89,7 @@ CREATE TABLE [{schema}].[Published]( [Added] [datetime2](7) NOT NULL, [ExpiresAt] [datetime2](7) NULL, [StatusName] [nvarchar](50) NOT NULL, - CONSTRAINT [PK_{schema}.Published] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_{schema}.Published] PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] @@ -100,4 +99,4 @@ GO"; return batchSQL; } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs b/src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs index 2a6466c..42df3f8 100644 --- a/src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs +++ b/src/DotNetCore.CAP.Kafka/CAP.KafkaCapOptionsExtension.cs @@ -25,4 +25,4 @@ namespace DotNetCore.CAP services.AddTransient(); } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP.Kafka/CAP.KafkaOptions.cs b/src/DotNetCore.CAP.Kafka/CAP.KafkaOptions.cs index 1c09b77..55b055b 100644 --- a/src/DotNetCore.CAP.Kafka/CAP.KafkaOptions.cs +++ b/src/DotNetCore.CAP.Kafka/CAP.KafkaOptions.cs @@ -32,9 +32,9 @@ namespace DotNetCore.CAP internal IEnumerable> AsRdkafkaConfig() { - if (MainConfig.ContainsKey("bootstrap.servers")) + if (MainConfig.ContainsKey("bootstrap.servers")) return MainConfig.AsEnumerable(); - + if (string.IsNullOrEmpty(Servers)) { throw new ArgumentNullException(nameof(Servers)); diff --git a/src/DotNetCore.CAP.Kafka/CAP.Options.Extensions.cs b/src/DotNetCore.CAP.Kafka/CAP.Options.Extensions.cs index 8afeece..c562251 100644 --- a/src/DotNetCore.CAP.Kafka/CAP.Options.Extensions.cs +++ b/src/DotNetCore.CAP.Kafka/CAP.Options.Extensions.cs @@ -1,6 +1,5 @@ using System; using DotNetCore.CAP; -using DotNetCore.CAP.Kafka; namespace Microsoft.Extensions.DependencyInjection { diff --git a/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs b/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs index a3c5503..014c9bd 100644 --- a/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs +++ b/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs @@ -81,7 +81,6 @@ namespace DotNetCore.CAP.Kafka MessageReceieved?.Invoke(sender, message); } - #endregion private methods } } \ No newline at end of file diff --git a/src/DotNetCore.CAP.Kafka/PublishQueueExecutor.cs b/src/DotNetCore.CAP.Kafka/PublishQueueExecutor.cs index e54975b..8252629 100644 --- a/src/DotNetCore.CAP.Kafka/PublishQueueExecutor.cs +++ b/src/DotNetCore.CAP.Kafka/PublishQueueExecutor.cs @@ -51,4 +51,4 @@ namespace DotNetCore.CAP.Kafka } } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs b/src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs index de82129..ddce147 100644 --- a/src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs +++ b/src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs @@ -72,7 +72,7 @@ public int SocketWriteTimeout { get; set; } = DefaultConnectionTimeout; /// - /// The port to connect on. + /// The port to connect on. /// public int Port { get; set; } = -1; } diff --git a/src/DotNetCore.CAP.RabbitMQ/CAP.RabbitMQCapOptionsExtension.cs b/src/DotNetCore.CAP.RabbitMQ/CAP.RabbitMQCapOptionsExtension.cs index 17f7faa..ee677c8 100644 --- a/src/DotNetCore.CAP.RabbitMQ/CAP.RabbitMQCapOptionsExtension.cs +++ b/src/DotNetCore.CAP.RabbitMQ/CAP.RabbitMQCapOptionsExtension.cs @@ -26,4 +26,4 @@ namespace DotNetCore.CAP services.AddTransient(); } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP.RabbitMQ/CapSubscribeAttribute.cs b/src/DotNetCore.CAP.RabbitMQ/CapSubscribeAttribute.cs index cfbbc8d..de63ac7 100644 --- a/src/DotNetCore.CAP.RabbitMQ/CapSubscribeAttribute.cs +++ b/src/DotNetCore.CAP.RabbitMQ/CapSubscribeAttribute.cs @@ -6,7 +6,6 @@ namespace DotNetCore.CAP.RabbitMQ { public CapSubscribeAttribute(string name) : base(name) { - } } } \ No newline at end of file diff --git a/src/DotNetCore.CAP.RabbitMQ/PublishQueueExecutor.cs b/src/DotNetCore.CAP.RabbitMQ/PublishQueueExecutor.cs index df08dd2..80f0cfb 100644 --- a/src/DotNetCore.CAP.RabbitMQ/PublishQueueExecutor.cs +++ b/src/DotNetCore.CAP.RabbitMQ/PublishQueueExecutor.cs @@ -64,7 +64,6 @@ namespace DotNetCore.CAP.RabbitMQ Description = ex.Message })); } - } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Abstractions/ModelBinding/IModelBinder.cs b/src/DotNetCore.CAP/Abstractions/ModelBinding/IModelBinder.cs index c8c976c..f03b105 100644 --- a/src/DotNetCore.CAP/Abstractions/ModelBinding/IModelBinder.cs +++ b/src/DotNetCore.CAP/Abstractions/ModelBinding/IModelBinder.cs @@ -14,7 +14,7 @@ namespace DotNetCore.CAP.Abstractions.ModelBinding /// /// /// A which will complete when the model binding process completes. - /// + /// /// Task BindModelAsync(ModelBindingContext bindingContext); } diff --git a/src/DotNetCore.CAP/CAP.Options.cs b/src/DotNetCore.CAP/CAP.Options.cs index 003f6c0..de6d1ae 100644 --- a/src/DotNetCore.CAP/CAP.Options.cs +++ b/src/DotNetCore.CAP/CAP.Options.cs @@ -35,7 +35,6 @@ namespace DotNetCore.CAP /// public int PollingDelay { get; set; } = 8; - /// /// Registers an extension that will be executed when building services. /// diff --git a/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs b/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs index f6fda76..2ba0faa 100644 --- a/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs +++ b/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs @@ -47,12 +47,12 @@ namespace Microsoft.Extensions.DependencyInjection //Processors services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); //Executors services.AddSingleton(); services.AddSingleton(); - + //Options var options = new CapOptions(); setupAction(options); diff --git a/src/DotNetCore.CAP/ICapOptionsExtension.cs b/src/DotNetCore.CAP/ICapOptionsExtension.cs index 5e29f50..bfeb693 100644 --- a/src/DotNetCore.CAP/ICapOptionsExtension.cs +++ b/src/DotNetCore.CAP/ICapOptionsExtension.cs @@ -6,4 +6,4 @@ namespace DotNetCore.CAP { void AddServices(IServiceCollection services); } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/ICapPublisher.cs b/src/DotNetCore.CAP/ICapPublisher.cs index 50c4a50..95f28b0 100644 --- a/src/DotNetCore.CAP/ICapPublisher.cs +++ b/src/DotNetCore.CAP/ICapPublisher.cs @@ -1,5 +1,4 @@ -using System; -using System.Data; +using System.Data; using System.Threading.Tasks; namespace DotNetCore.CAP @@ -21,7 +20,7 @@ namespace DotNetCore.CAP Task PublishAsync(string name, string content); /// - /// Publis a object message to specified topic. + /// Publis a object message to specified topic. /// /// If you are using the EntityFramework, you need to configure the DbContextType first. /// otherwise you need to use overloaded method with IDbConnection and IDbTransaction. diff --git a/src/DotNetCore.CAP/IConsumerHandler.Default.cs b/src/DotNetCore.CAP/IConsumerHandler.Default.cs index 706fb64..0ca1949 100644 --- a/src/DotNetCore.CAP/IConsumerHandler.Default.cs +++ b/src/DotNetCore.CAP/IConsumerHandler.Default.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using System.Threading; using System.Threading.Tasks; using DotNetCore.CAP.Infrastructure; diff --git a/src/DotNetCore.CAP/IQueueExecutor.cs b/src/DotNetCore.CAP/IQueueExecutor.cs index 7135eed..ad4a6b1 100644 --- a/src/DotNetCore.CAP/IQueueExecutor.cs +++ b/src/DotNetCore.CAP/IQueueExecutor.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; +using System.Threading.Tasks; namespace DotNetCore.CAP { @@ -9,4 +6,4 @@ namespace DotNetCore.CAP { Task ExecuteAsync(IStorageConnection connection, IFetchedMessage message); } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/IStorage.cs b/src/DotNetCore.CAP/IStorage.cs index 1140411..ea5726d 100644 --- a/src/DotNetCore.CAP/IStorage.cs +++ b/src/DotNetCore.CAP/IStorage.cs @@ -3,14 +3,14 @@ using System.Threading.Tasks; namespace DotNetCore.CAP { - /// - /// Represents a persisted storage. - /// - public interface IStorage - { - /// - /// Initializes the storage. For example, making sure a database is created and migrations are applied. - /// - Task InitializeAsync(CancellationToken cancellationToken); - } -} + /// + /// Represents a persisted storage. + /// + public interface IStorage + { + /// + /// Initializes the storage. For example, making sure a database is created and migrations are applied. + /// + Task InitializeAsync(CancellationToken cancellationToken); + } +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/IStorageTransaction.cs b/src/DotNetCore.CAP/IStorageTransaction.cs index 642cc4d..788d4e1 100644 --- a/src/DotNetCore.CAP/IStorageTransaction.cs +++ b/src/DotNetCore.CAP/IStorageTransaction.cs @@ -4,16 +4,16 @@ using DotNetCore.CAP.Models; namespace DotNetCore.CAP { - public interface IStorageTransaction : IDisposable - { - void UpdateMessage(CapPublishedMessage message); + public interface IStorageTransaction : IDisposable + { + void UpdateMessage(CapPublishedMessage message); - void UpdateMessage(CapReceivedMessage message); + void UpdateMessage(CapReceivedMessage message); - void EnqueueMessage(CapPublishedMessage message); + void EnqueueMessage(CapPublishedMessage message); - void EnqueueMessage(CapReceivedMessage message); + void EnqueueMessage(CapReceivedMessage message); - Task CommitAsync(); - } -} + Task CommitAsync(); + } +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Infrastructure/Helper.cs b/src/DotNetCore.CAP/Infrastructure/Helper.cs index e254fed..a4c36e2 100644 --- a/src/DotNetCore.CAP/Infrastructure/Helper.cs +++ b/src/DotNetCore.CAP/Infrastructure/Helper.cs @@ -40,7 +40,7 @@ namespace DotNetCore.CAP.Infrastructure public static long ToTimestamp(DateTime value) { var elapsedTime = value - Epoch; - return (long) elapsedTime.TotalSeconds; + return (long)elapsedTime.TotalSeconds; } public static DateTime FromTimestamp(long value) diff --git a/src/DotNetCore.CAP/Infrastructure/StatusName.cs b/src/DotNetCore.CAP/Infrastructure/StatusName.cs index 2841d84..62ee0fd 100644 --- a/src/DotNetCore.CAP/Infrastructure/StatusName.cs +++ b/src/DotNetCore.CAP/Infrastructure/StatusName.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace DotNetCore.CAP.Infrastructure +namespace DotNetCore.CAP.Infrastructure { /// /// The message status name. @@ -15,4 +11,4 @@ namespace DotNetCore.CAP.Infrastructure public const string Succeeded = nameof(Succeeded); public const string Failed = nameof(Failed); } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Infrastructure/WaitHandleEx.cs b/src/DotNetCore.CAP/Infrastructure/WaitHandleEx.cs index 5a277d2..4afa6d6 100644 --- a/src/DotNetCore.CAP/Infrastructure/WaitHandleEx.cs +++ b/src/DotNetCore.CAP/Infrastructure/WaitHandleEx.cs @@ -21,7 +21,7 @@ namespace DotNetCore.CAP.Infrastructure var tcs = new TaskCompletionSource(); registeredHandle = ThreadPool.RegisterWaitForSingleObject( handle, - (state, timedOut) => ((TaskCompletionSource) state).TrySetResult(!timedOut), + (state, timedOut) => ((TaskCompletionSource)state).TrySetResult(!timedOut), tcs, timeout, true); diff --git a/src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs b/src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs index 44721d2..ab67b97 100644 --- a/src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs +++ b/src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs @@ -44,7 +44,6 @@ namespace DotNetCore.CAP.Internal return executorDescriptorList; } - private static IEnumerable FindConsumersFromInterfaceTypes( IServiceProvider provider) { diff --git a/src/DotNetCore.CAP/Internal/MethodMatcherCache.cs b/src/DotNetCore.CAP/Internal/MethodMatcherCache.cs index 0483ab7..332158b 100644 --- a/src/DotNetCore.CAP/Internal/MethodMatcherCache.cs +++ b/src/DotNetCore.CAP/Internal/MethodMatcherCache.cs @@ -1,7 +1,7 @@ using System; -using System.Linq; using System.Collections.Concurrent; using System.Collections.Generic; +using System.Linq; using DotNetCore.CAP.Abstractions; namespace DotNetCore.CAP.Internal @@ -41,7 +41,7 @@ namespace DotNetCore.CAP.Internal /// /// Get a dictionary of specify topic candidates. - /// The Key is Group name, the value is specify topic candidates. + /// The Key is Group name, the value is specify topic candidates. /// /// message topic name public IDictionary> GetTopicExector(string topicName) diff --git a/src/DotNetCore.CAP/Internal/ObjectMethodExecutor.cs b/src/DotNetCore.CAP/Internal/ObjectMethodExecutor.cs index ca81421..cb0f99d 100644 --- a/src/DotNetCore.CAP/Internal/ObjectMethodExecutor.cs +++ b/src/DotNetCore.CAP/Internal/ObjectMethodExecutor.cs @@ -130,7 +130,7 @@ namespace DotNetCore.CAP.Internal private static ConsumerMethodExecutor WrapVoidAction(VoidActionExecutor executor) { - return delegate(object target, object[] parameters) + return delegate (object target, object[] parameters) { executor(target, parameters); return null; @@ -192,7 +192,7 @@ namespace DotNetCore.CAP.Internal /// private static async Task CastToObject(Task task) { - return (object) await task; + return (object)await task; } private static Type GetTaskInnerTypeOrNull(Type type) @@ -279,7 +279,7 @@ namespace DotNetCore.CAP.Internal private static Task Convert(object taskAsObject) { - var task = (Task) taskAsObject; + var task = (Task)taskAsObject; return CastToObject(task); } diff --git a/src/DotNetCore.CAP/Internal/SubscriberNotFoundException.cs b/src/DotNetCore.CAP/Internal/SubscriberNotFoundException.cs index 4bf9844..4889a8a 100644 --- a/src/DotNetCore.CAP/Internal/SubscriberNotFoundException.cs +++ b/src/DotNetCore.CAP/Internal/SubscriberNotFoundException.cs @@ -1,13 +1,19 @@ using System; + namespace DotNetCore.CAP.Internal { public class SubscriberNotFoundException : Exception { - public SubscriberNotFoundException() { } + public SubscriberNotFoundException() + { + } - public SubscriberNotFoundException(string message) : base(message) { } + public SubscriberNotFoundException(string message) : base(message) + { + } public SubscriberNotFoundException(string message, Exception inner) : - base(message, inner) { } + base(message, inner) + { } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/LoggerExtensions.cs b/src/DotNetCore.CAP/LoggerExtensions.cs index 5bb3ee5..c921247 100644 --- a/src/DotNetCore.CAP/LoggerExtensions.cs +++ b/src/DotNetCore.CAP/LoggerExtensions.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using DotNetCore.CAP.Processor; using Microsoft.Extensions.Logging; namespace DotNetCore.CAP @@ -66,7 +63,6 @@ namespace DotNetCore.CAP 5, "Received message topic method '{topicName}' failed to execute."); - _jobRetrying = LoggerMessage.Define( LogLevel.Debug, 3, @@ -104,19 +100,16 @@ namespace DotNetCore.CAP _jobFailedWillRetry(logger, ex); } - public static void JobRetrying(this ILogger logger, int retries) { _jobRetrying(logger, retries, null); } - public static void JobExecuted(this ILogger logger, double seconds) { _jobExecuted(logger, seconds, null); } - public static void ConsumerMethodExecutingFailed(this ILogger logger, string methodName, Exception ex) { _executingConsumerMethod(logger, methodName, ex); diff --git a/src/DotNetCore.CAP/Models/CapPublishedMessage.cs b/src/DotNetCore.CAP/Models/CapPublishedMessage.cs index 7780a09..24dfbcc 100644 --- a/src/DotNetCore.CAP/Models/CapPublishedMessage.cs +++ b/src/DotNetCore.CAP/Models/CapPublishedMessage.cs @@ -3,7 +3,7 @@ using DotNetCore.CAP.Infrastructure; namespace DotNetCore.CAP.Models { - public class CapPublishedMessage + public class CapPublishedMessage { /// /// Initializes a new instance of . @@ -22,7 +22,7 @@ namespace DotNetCore.CAP.Models Content = message.Content; } - public int Id { get; set; } + public int Id { get; set; } public string Name { get; set; } diff --git a/src/DotNetCore.CAP/Models/CapQueue.cs b/src/DotNetCore.CAP/Models/CapQueue.cs index e8c0da1..d0aa41c 100644 --- a/src/DotNetCore.CAP/Models/CapQueue.cs +++ b/src/DotNetCore.CAP/Models/CapQueue.cs @@ -9,4 +9,4 @@ /// public MessageType MessageType { get; set; } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Models/MessageType.cs b/src/DotNetCore.CAP/Models/MessageType.cs index 1ddfc74..5097962 100644 --- a/src/DotNetCore.CAP/Models/MessageType.cs +++ b/src/DotNetCore.CAP/Models/MessageType.cs @@ -5,4 +5,4 @@ Publish, Subscribe } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/OperateResult.cs b/src/DotNetCore.CAP/OperateResult.cs index 41fcc33..04aa787 100644 --- a/src/DotNetCore.CAP/OperateResult.cs +++ b/src/DotNetCore.CAP/OperateResult.cs @@ -32,7 +32,7 @@ namespace DotNetCore.CAP /// Returns an indicating a successful identity operation. /// /// An indicating a successful operation. - public static OperateResult Success { get; } = new OperateResult {Succeeded = true}; + public static OperateResult Success { get; } = new OperateResult { Succeeded = true }; /// /// Creates an indicating a failed operation, with a list of if applicable. @@ -41,7 +41,7 @@ namespace DotNetCore.CAP /// An indicating a failed operation, with a list of if applicable. public static OperateResult Failed(params OperateError[] errors) { - var result = new OperateResult {Succeeded = false}; + var result = new OperateResult { Succeeded = false }; if (errors != null) { result._errors.AddRange(errors); diff --git a/src/DotNetCore.CAP/Processor/IAdditionalProcessor.cs b/src/DotNetCore.CAP/Processor/IAdditionalProcessor.cs index 9c414ff..b678614 100644 --- a/src/DotNetCore.CAP/Processor/IAdditionalProcessor.cs +++ b/src/DotNetCore.CAP/Processor/IAdditionalProcessor.cs @@ -1,11 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace DotNetCore.CAP.Processor +namespace DotNetCore.CAP.Processor { public interface IAdditionalProcessor : IProcessor { - } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Processor/IDispatcher.Default.cs b/src/DotNetCore.CAP/Processor/IDispatcher.Default.cs index 1066ddf..53a0a73 100644 --- a/src/DotNetCore.CAP/Processor/IDispatcher.Default.cs +++ b/src/DotNetCore.CAP/Processor/IDispatcher.Default.cs @@ -93,4 +93,4 @@ namespace DotNetCore.CAP.Processor return fetched != null; } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Processor/IDispatcher.cs b/src/DotNetCore.CAP/Processor/IDispatcher.cs index f358ac6..f612d02 100644 --- a/src/DotNetCore.CAP/Processor/IDispatcher.cs +++ b/src/DotNetCore.CAP/Processor/IDispatcher.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace DotNetCore.CAP.Processor +namespace DotNetCore.CAP.Processor { public interface IDispatcher : IProcessor { bool Waiting { get; } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Processor/IProcessor.PublishQueuer.cs b/src/DotNetCore.CAP/Processor/IProcessor.PublishQueuer.cs index ec0faf3..4537c17 100644 --- a/src/DotNetCore.CAP/Processor/IProcessor.PublishQueuer.cs +++ b/src/DotNetCore.CAP/Processor/IProcessor.PublishQueuer.cs @@ -2,67 +2,67 @@ using System.Threading; using System.Threading.Tasks; using DotNetCore.CAP.Infrastructure; -using DotNetCore.CAP.Processor.States; using DotNetCore.CAP.Models; +using DotNetCore.CAP.Processor.States; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; namespace DotNetCore.CAP.Processor { - public class PublishQueuer : IProcessor + public class PublishQueuer : IProcessor { - private ILogger _logger; - private CapOptions _options; - private IStateChanger _stateChanger; - private IServiceProvider _provider; - private TimeSpan _pollingDelay; + private ILogger _logger; + private CapOptions _options; + private IStateChanger _stateChanger; + private IServiceProvider _provider; + private TimeSpan _pollingDelay; public static readonly AutoResetEvent PulseEvent = new AutoResetEvent(true); public PublishQueuer( - ILogger logger, - IOptions options, - IStateChanger stateChanger, - IServiceProvider provider) - { - _logger = logger; - _options = options.Value; - _stateChanger = stateChanger; - _provider = provider; + ILogger logger, + IOptions options, + IStateChanger stateChanger, + IServiceProvider provider) + { + _logger = logger; + _options = options.Value; + _stateChanger = stateChanger; + _provider = provider; - _pollingDelay = TimeSpan.FromSeconds(_options.PollingDelay); - } + _pollingDelay = TimeSpan.FromSeconds(_options.PollingDelay); + } - public async Task ProcessAsync(ProcessingContext context) - { - using (var scope = _provider.CreateScope()) - { + public async Task ProcessAsync(ProcessingContext context) + { + using (var scope = _provider.CreateScope()) + { CapPublishedMessage sentMessage; - var provider = scope.ServiceProvider; - var connection = provider.GetRequiredService(); + var provider = scope.ServiceProvider; + var connection = provider.GetRequiredService(); - while ( - !context.IsStopping && - (sentMessage = await connection.GetNextPublishedMessageToBeEnqueuedAsync()) != null) + while ( + !context.IsStopping && + (sentMessage = await connection.GetNextPublishedMessageToBeEnqueuedAsync()) != null) { var state = new EnqueuedState(); - using (var transaction = connection.CreateTransaction()) - { - _stateChanger.ChangeState(sentMessage, state, transaction); - await transaction.CommitAsync(); - } - } - } + using (var transaction = connection.CreateTransaction()) + { + _stateChanger.ChangeState(sentMessage, state, transaction); + await transaction.CommitAsync(); + } + } + } context.ThrowIfStopping(); - + DefaultDispatcher.PulseEvent.Set(); await WaitHandleEx.WaitAnyAsync(PulseEvent, context.CancellationToken.WaitHandle, _pollingDelay); - } - } -} + } + } +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Processor/IProcessor.SubscribeQueuer.cs b/src/DotNetCore.CAP/Processor/IProcessor.SubscribeQueuer.cs index 17c2425..4a85fb0 100644 --- a/src/DotNetCore.CAP/Processor/IProcessor.SubscribeQueuer.cs +++ b/src/DotNetCore.CAP/Processor/IProcessor.SubscribeQueuer.cs @@ -2,8 +2,8 @@ using System.Threading; using System.Threading.Tasks; using DotNetCore.CAP.Infrastructure; -using DotNetCore.CAP.Processor.States; using DotNetCore.CAP.Models; +using DotNetCore.CAP.Processor.States; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -65,4 +65,4 @@ namespace DotNetCore.CAP.Processor context.CancellationToken.WaitHandle, _pollingDelay); } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Processor/RetryBehavior.cs b/src/DotNetCore.CAP/Processor/RetryBehavior.cs index 04cb667..1421fae 100644 --- a/src/DotNetCore.CAP/Processor/RetryBehavior.cs +++ b/src/DotNetCore.CAP/Processor/RetryBehavior.cs @@ -18,7 +18,7 @@ namespace DotNetCore.CAP.Processor { DefaultRetryCount = 25; DefaultRetryInThunk = retries => - (int) Math.Round(Math.Pow(retries - 1, 4) + 15 + (_random.Next(30) * (retries))); + (int)Math.Round(Math.Pow(retries - 1, 4) + 15 + (_random.Next(30) * (retries))); DefaultRetry = new RetryBehavior(true); NoRetry = new RetryBehavior(false); diff --git a/src/DotNetCore.CAP/QueueExecutorFactory.cs b/src/DotNetCore.CAP/QueueExecutorFactory.cs index 1c71e93..7790167 100644 --- a/src/DotNetCore.CAP/QueueExecutorFactory.cs +++ b/src/DotNetCore.CAP/QueueExecutorFactory.cs @@ -18,8 +18,8 @@ namespace DotNetCore.CAP public IQueueExecutor GetInstance(MessageType messageType) { var _queueExectors = _serviceProvider.GetServices(); - - if (messageType== MessageType.Publish) + + if (messageType == MessageType.Publish) { return _queueExectors.FirstOrDefault(x => typeof(BasePublishQueueExecutor).IsAssignableFrom(x.GetType())); } @@ -29,4 +29,4 @@ namespace DotNetCore.CAP } } } -} +} \ No newline at end of file