From b3aeb1a2479d7d1ca63270004a581ede6c0ac756 Mon Sep 17 00:00:00 2001 From: Savorboard Date: Mon, 18 Nov 2019 16:46:10 +0800 Subject: [PATCH] Refactoring namespace --- .../AzureServiceBusConsumerClient.cs | 1 + .../AzureServiceBusConsumerClientFactory.cs | 1 + .../DashboardRoutes.cs | 2 + .../CAP.DiscoveryOptionsExtensions.cs | 1 + .../NodeDiscovery/IProcessingServer.Consul.cs | 2 + .../ICapTransaction.InMemory.cs | 1 + .../KafkaConsumerClient.cs | 1 + .../KafkaConsumerClientFactory.cs | 1 + .../ICapTransaction.MongoDB.cs | 1 + .../ICapTransaction.MySql.cs | 1 + .../ICapTransaction.PostgreSql.cs | 1 + .../RabbitMQConsumerClient.cs | 1 + .../RabbitMQConsumerClientFactory.cs | 1 + .../Diagnostics/DiagnosticObserver.cs | 1 + .../DiagnosticProcessorObserver.cs | 1 + .../ICapTransaction.SqlServer.cs | 1 + .../Abstractions/IModelBinderFactory.cs | 21 - .../Abstractions/ModelBinding/IModelBinder.cs | 15 - .../ModelBinding/ModelBindingResult.cs | 104 ---- src/DotNetCore.CAP/CAP.Attribute.cs | 2 +- src/DotNetCore.CAP/CAP.Builder.cs | 1 - .../CAP.ServiceCollectionExtensions.cs | 2 +- src/DotNetCore.CAP/ICapTransaction.Base.cs | 1 + .../ConsumerExecutorDescriptor.cs | 3 +- .../Internal/ConsumerInvokerFactory.cs | 1 - .../{ => Internal}/IBootstrapper.Default.cs | 4 +- .../{ => Internal}/IBootstrapper.cs | 2 +- .../ICapPublisher.Default.cs} | 6 +- .../IConsumerRegister.Default.cs | 6 +- .../{ => Internal}/IConsumerRegister.cs | 2 +- .../IConsumerServiceSelector.Default.cs | 464 +++++++++--------- .../IConsumerServiceSelector.cs | 2 +- .../IMongoTransaction.cs | 6 +- .../{ => Internal}/IProcessingServer.cs | 2 +- .../ISubscriberExecutor.Default.cs} | 5 +- .../{ => Internal}/ISubscriberExecutor.cs | 2 +- .../Internal/LoggerExtensions.cs | 2 +- .../TopicAttribute.cs | 2 +- .../Monitoring/MessageQueryDto.cs | 1 + .../Processor/IDispatcher.Default.cs | 1 + .../Processor/IProcessingServer.Cap.cs | 1 + .../Processor/IProcessor.TransportCheck.cs | 1 + .../{ => Transport}/IConsumerClient.cs | 2 +- .../{ => Transport}/IConsumerClientFactory.cs | 2 +- .../{ => Transport}/IDispatcher.cs | 3 +- .../{ => Transport}/MqLogType.cs | 2 +- .../ModelBinderFactoryTest.cs | 46 -- test/DotNetCore.CAP.Test/SnowflakeIdTest.cs | 2 +- 48 files changed, 282 insertions(+), 452 deletions(-) delete mode 100644 src/DotNetCore.CAP/Abstractions/IModelBinderFactory.cs delete mode 100644 src/DotNetCore.CAP/Abstractions/ModelBinding/IModelBinder.cs delete mode 100644 src/DotNetCore.CAP/Abstractions/ModelBinding/ModelBindingResult.cs rename src/DotNetCore.CAP/{ => Internal}/ConsumerExecutorDescriptor.cs (93%) rename src/DotNetCore.CAP/{ => Internal}/IBootstrapper.Default.cs (95%) rename src/DotNetCore.CAP/{ => Internal}/IBootstrapper.cs (93%) rename src/DotNetCore.CAP/{Abstractions/CapPublisher.cs => Internal/ICapPublisher.Default.cs} (97%) rename src/DotNetCore.CAP/{ => Internal}/IConsumerRegister.Default.cs (99%) rename src/DotNetCore.CAP/{ => Internal}/IConsumerRegister.cs (91%) rename src/DotNetCore.CAP/{ => Internal}/IConsumerServiceSelector.Default.cs (96%) rename src/DotNetCore.CAP/{ => Internal}/IConsumerServiceSelector.cs (97%) rename src/DotNetCore.CAP/{Abstractions => Internal}/IMongoTransaction.cs (73%) rename src/DotNetCore.CAP/{ => Internal}/IProcessingServer.cs (91%) rename src/DotNetCore.CAP/{ISubscribeExecutor.Default.cs => Internal/ISubscriberExecutor.Default.cs} (99%) rename src/DotNetCore.CAP/{ => Internal}/ISubscriberExecutor.cs (94%) rename src/DotNetCore.CAP/{Abstractions => Internal}/TopicAttribute.cs (95%) rename src/DotNetCore.CAP/{ => Transport}/IConsumerClient.cs (97%) rename src/DotNetCore.CAP/{ => Transport}/IConsumerClientFactory.cs (93%) rename src/DotNetCore.CAP/{ => Transport}/IDispatcher.cs (85%) rename src/DotNetCore.CAP/{ => Transport}/MqLogType.cs (94%) delete mode 100644 test/DotNetCore.CAP.Test/ModelBinderFactoryTest.cs diff --git a/src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerClient.cs b/src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerClient.cs index 5a69eb7..ceb7b13 100644 --- a/src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerClient.cs +++ b/src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerClient.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using DotNetCore.CAP.Messages; +using DotNetCore.CAP.Transport; using Microsoft.Azure.ServiceBus; using Microsoft.Azure.ServiceBus.Management; using Microsoft.Extensions.Logging; diff --git a/src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerClientFactory.cs b/src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerClientFactory.cs index 20f25f6..d7dd426 100644 --- a/src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerClientFactory.cs +++ b/src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerClientFactory.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Core Community. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. +using DotNetCore.CAP.Transport; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; diff --git a/src/DotNetCore.CAP.Dashboard/DashboardRoutes.cs b/src/DotNetCore.CAP.Dashboard/DashboardRoutes.cs index 3ba3ba8..86b04aa 100644 --- a/src/DotNetCore.CAP.Dashboard/DashboardRoutes.cs +++ b/src/DotNetCore.CAP.Dashboard/DashboardRoutes.cs @@ -3,6 +3,8 @@ using System.Reflection; using DotNetCore.CAP.Dashboard.Pages; +using DotNetCore.CAP.Internal; +using DotNetCore.CAP.Transport; using Microsoft.Extensions.DependencyInjection; namespace DotNetCore.CAP.Dashboard diff --git a/src/DotNetCore.CAP.Dashboard/NodeDiscovery/CAP.DiscoveryOptionsExtensions.cs b/src/DotNetCore.CAP.Dashboard/NodeDiscovery/CAP.DiscoveryOptionsExtensions.cs index 400e91c..488f3cb 100644 --- a/src/DotNetCore.CAP.Dashboard/NodeDiscovery/CAP.DiscoveryOptionsExtensions.cs +++ b/src/DotNetCore.CAP.Dashboard/NodeDiscovery/CAP.DiscoveryOptionsExtensions.cs @@ -3,6 +3,7 @@ using System; using DotNetCore.CAP; +using DotNetCore.CAP.Internal; using Microsoft.Extensions.DependencyInjection; namespace DotNetCore.CAP.Dashboard.NodeDiscovery diff --git a/src/DotNetCore.CAP.Dashboard/NodeDiscovery/IProcessingServer.Consul.cs b/src/DotNetCore.CAP.Dashboard/NodeDiscovery/IProcessingServer.Consul.cs index c801698..9dd565b 100644 --- a/src/DotNetCore.CAP.Dashboard/NodeDiscovery/IProcessingServer.Consul.cs +++ b/src/DotNetCore.CAP.Dashboard/NodeDiscovery/IProcessingServer.Consul.cs @@ -1,6 +1,8 @@ // Copyright (c) .NET Core Community. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. +using DotNetCore.CAP.Internal; + namespace DotNetCore.CAP.Dashboard.NodeDiscovery { internal class ConsulProcessingNodeServer : IProcessingServer diff --git a/src/DotNetCore.CAP.InMemoryStorage/ICapTransaction.InMemory.cs b/src/DotNetCore.CAP.InMemoryStorage/ICapTransaction.InMemory.cs index e4813be..6d99bc5 100644 --- a/src/DotNetCore.CAP.InMemoryStorage/ICapTransaction.InMemory.cs +++ b/src/DotNetCore.CAP.InMemoryStorage/ICapTransaction.InMemory.cs @@ -5,6 +5,7 @@ using System.Threading; using System.Threading.Tasks; +using DotNetCore.CAP.Transport; namespace DotNetCore.CAP.InMemoryStorage { diff --git a/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs b/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs index a78eb9f..d9e111e 100644 --- a/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs +++ b/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading; using Confluent.Kafka; using DotNetCore.CAP.Messages; +using DotNetCore.CAP.Transport; using Microsoft.Extensions.Options; namespace DotNetCore.CAP.Kafka diff --git a/src/DotNetCore.CAP.Kafka/KafkaConsumerClientFactory.cs b/src/DotNetCore.CAP.Kafka/KafkaConsumerClientFactory.cs index 1c1ebf0..59374bd 100644 --- a/src/DotNetCore.CAP.Kafka/KafkaConsumerClientFactory.cs +++ b/src/DotNetCore.CAP.Kafka/KafkaConsumerClientFactory.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Core Community. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. +using DotNetCore.CAP.Transport; using Microsoft.Extensions.Options; namespace DotNetCore.CAP.Kafka diff --git a/src/DotNetCore.CAP.MongoDB/ICapTransaction.MongoDB.cs b/src/DotNetCore.CAP.MongoDB/ICapTransaction.MongoDB.cs index ce9aae3..1694b86 100644 --- a/src/DotNetCore.CAP.MongoDB/ICapTransaction.MongoDB.cs +++ b/src/DotNetCore.CAP.MongoDB/ICapTransaction.MongoDB.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.Threading; using System.Threading.Tasks; +using DotNetCore.CAP.Transport; using Microsoft.Extensions.DependencyInjection; using MongoDB.Driver; diff --git a/src/DotNetCore.CAP.MySql/ICapTransaction.MySql.cs b/src/DotNetCore.CAP.MySql/ICapTransaction.MySql.cs index fac7430..66c320e 100644 --- a/src/DotNetCore.CAP.MySql/ICapTransaction.MySql.cs +++ b/src/DotNetCore.CAP.MySql/ICapTransaction.MySql.cs @@ -5,6 +5,7 @@ using System.Data; using System.Diagnostics; using System.Threading; using System.Threading.Tasks; +using DotNetCore.CAP.Transport; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.Extensions.DependencyInjection; diff --git a/src/DotNetCore.CAP.PostgreSql/ICapTransaction.PostgreSql.cs b/src/DotNetCore.CAP.PostgreSql/ICapTransaction.PostgreSql.cs index 012578c..76aeb20 100644 --- a/src/DotNetCore.CAP.PostgreSql/ICapTransaction.PostgreSql.cs +++ b/src/DotNetCore.CAP.PostgreSql/ICapTransaction.PostgreSql.cs @@ -5,6 +5,7 @@ using System.Data; using System.Diagnostics; using System.Threading; using System.Threading.Tasks; +using DotNetCore.CAP.Transport; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.Extensions.DependencyInjection; diff --git a/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs index ba65bd4..2e61906 100644 --- a/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs +++ b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Text; using System.Threading; using DotNetCore.CAP.Messages; +using DotNetCore.CAP.Transport; using Microsoft.Extensions.Options; using RabbitMQ.Client; using RabbitMQ.Client.Events; diff --git a/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs index 0a9d541..ff178b5 100644 --- a/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs +++ b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Core Community. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. +using DotNetCore.CAP.Transport; using Microsoft.Extensions.Options; namespace DotNetCore.CAP.RabbitMQ diff --git a/src/DotNetCore.CAP.SqlServer/Diagnostics/DiagnosticObserver.cs b/src/DotNetCore.CAP.SqlServer/Diagnostics/DiagnosticObserver.cs index 432185a..1f43bd7 100644 --- a/src/DotNetCore.CAP.SqlServer/Diagnostics/DiagnosticObserver.cs +++ b/src/DotNetCore.CAP.SqlServer/Diagnostics/DiagnosticObserver.cs @@ -6,6 +6,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Reflection; using DotNetCore.CAP.Persistence; +using DotNetCore.CAP.Transport; using Microsoft.Data.SqlClient; namespace DotNetCore.CAP.SqlServer.Diagnostics diff --git a/src/DotNetCore.CAP.SqlServer/Diagnostics/DiagnosticProcessorObserver.cs b/src/DotNetCore.CAP.SqlServer/Diagnostics/DiagnosticProcessorObserver.cs index 53b22cc..ea14ca2 100644 --- a/src/DotNetCore.CAP.SqlServer/Diagnostics/DiagnosticProcessorObserver.cs +++ b/src/DotNetCore.CAP.SqlServer/Diagnostics/DiagnosticProcessorObserver.cs @@ -6,6 +6,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using DotNetCore.CAP.Persistence; +using DotNetCore.CAP.Transport; namespace DotNetCore.CAP.SqlServer.Diagnostics { diff --git a/src/DotNetCore.CAP.SqlServer/ICapTransaction.SqlServer.cs b/src/DotNetCore.CAP.SqlServer/ICapTransaction.SqlServer.cs index 817c983..7a7d4e9 100644 --- a/src/DotNetCore.CAP.SqlServer/ICapTransaction.SqlServer.cs +++ b/src/DotNetCore.CAP.SqlServer/ICapTransaction.SqlServer.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using DotNetCore.CAP.Internal; using DotNetCore.CAP.Persistence; using DotNetCore.CAP.SqlServer.Diagnostics; +using DotNetCore.CAP.Transport; using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/src/DotNetCore.CAP/Abstractions/IModelBinderFactory.cs b/src/DotNetCore.CAP/Abstractions/IModelBinderFactory.cs deleted file mode 100644 index ce5de92..0000000 --- a/src/DotNetCore.CAP/Abstractions/IModelBinderFactory.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) .NET Core Community. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -using System.Reflection; -using DotNetCore.CAP.Abstractions.ModelBinding; - -namespace DotNetCore.CAP.Abstractions -{ - /// - /// Model binder factory. - /// - public interface IModelBinderFactory - { - /// - /// Create a model binder by parameter. - /// - /// The method parameter info - /// A model binder instance. - IModelBinder CreateBinder(ParameterInfo parameter); - } -} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Abstractions/ModelBinding/IModelBinder.cs b/src/DotNetCore.CAP/Abstractions/ModelBinding/IModelBinder.cs deleted file mode 100644 index 6914c47..0000000 --- a/src/DotNetCore.CAP/Abstractions/ModelBinding/IModelBinder.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) .NET Core Community. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -using System.Threading.Tasks; - -namespace DotNetCore.CAP.Abstractions.ModelBinding -{ - /// - /// Defines an interface for model binders. - /// - public interface IModelBinder - { - Task BindModelAsync(string content); - } -} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Abstractions/ModelBinding/ModelBindingResult.cs b/src/DotNetCore.CAP/Abstractions/ModelBinding/ModelBindingResult.cs deleted file mode 100644 index 62a9337..0000000 --- a/src/DotNetCore.CAP/Abstractions/ModelBinding/ModelBindingResult.cs +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) .NET Core Community. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -using DotNetCore.CAP.Internal; - -namespace DotNetCore.CAP.Abstractions.ModelBinding -{ - /// - /// Contains the result of model binding. - /// - public struct ModelBindingResult - { - /// - /// Creates a representing a failed model binding operation. - /// - /// A representing a failed model binding operation. - public static ModelBindingResult Failed() - { - return new ModelBindingResult(null, false); - } - - /// - /// Creates a representing a successful model binding operation. - /// - /// The model value. May be null. - /// A representing a successful model bind. - public static ModelBindingResult Success(object model) - { - return new ModelBindingResult(model, true); - } - - private ModelBindingResult(object model, bool isSuccess) - { - Model = model; - IsSuccess = isSuccess; - } - - /// - /// Gets the model associated with this context. - /// - public object Model { get; } - - public bool IsSuccess { get; } - - public override string ToString() - { - if (IsSuccess) - { - return $"Success '{Model}'"; - } - - return "Failed"; - } - - public override bool Equals(object obj) - { - var other = obj as ModelBindingResult?; - if (other == null) - { - return false; - } - - return Equals(other.Value); - } - - public override int GetHashCode() - { - var hashCodeCombiner = HashCodeCombiner.Start(); - hashCodeCombiner.Add(IsSuccess); - hashCodeCombiner.Add(Model); - - return hashCodeCombiner.CombinedHash; - } - - public bool Equals(ModelBindingResult other) - { - return - IsSuccess == other.IsSuccess && - Equals(Model, other.Model); - } - - /// - /// Compares objects for equality. - /// - /// A . - /// A . - /// true if the objects are equal, otherwise false. - public static bool operator ==(ModelBindingResult x, ModelBindingResult y) - { - return x.Equals(y); - } - - /// - /// Compares objects for inequality. - /// - /// A . - /// A . - /// true if the objects are not equal, otherwise false. - public static bool operator !=(ModelBindingResult x, ModelBindingResult y) - { - return !x.Equals(y); - } - } -} \ No newline at end of file diff --git a/src/DotNetCore.CAP/CAP.Attribute.cs b/src/DotNetCore.CAP/CAP.Attribute.cs index 242bc47..40092a5 100644 --- a/src/DotNetCore.CAP/CAP.Attribute.cs +++ b/src/DotNetCore.CAP/CAP.Attribute.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using DotNetCore.CAP.Abstractions; +using DotNetCore.CAP.Internal; // ReSharper disable once CheckNamespace namespace DotNetCore.CAP diff --git a/src/DotNetCore.CAP/CAP.Builder.cs b/src/DotNetCore.CAP/CAP.Builder.cs index c737b8a..ba58e2c 100644 --- a/src/DotNetCore.CAP/CAP.Builder.cs +++ b/src/DotNetCore.CAP/CAP.Builder.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. See License.txt in the project root for license information. using System; -using DotNetCore.CAP.Abstractions; using Microsoft.Extensions.DependencyInjection; namespace DotNetCore.CAP diff --git a/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs b/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs index 2275439..bd59c21 100644 --- a/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs +++ b/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs @@ -3,10 +3,10 @@ using System; using DotNetCore.CAP; -using DotNetCore.CAP.Abstractions; using DotNetCore.CAP.Internal; using DotNetCore.CAP.Processor; using DotNetCore.CAP.Serialization; +using DotNetCore.CAP.Transport; using Microsoft.Extensions.DependencyInjection.Extensions; // ReSharper disable once CheckNamespace diff --git a/src/DotNetCore.CAP/ICapTransaction.Base.cs b/src/DotNetCore.CAP/ICapTransaction.Base.cs index 1df1af2..6a9a92e 100644 --- a/src/DotNetCore.CAP/ICapTransaction.Base.cs +++ b/src/DotNetCore.CAP/ICapTransaction.Base.cs @@ -2,6 +2,7 @@ using System.Threading; using System.Threading.Tasks; using DotNetCore.CAP.Persistence; +using DotNetCore.CAP.Transport; namespace DotNetCore.CAP { diff --git a/src/DotNetCore.CAP/ConsumerExecutorDescriptor.cs b/src/DotNetCore.CAP/Internal/ConsumerExecutorDescriptor.cs similarity index 93% rename from src/DotNetCore.CAP/ConsumerExecutorDescriptor.cs rename to src/DotNetCore.CAP/Internal/ConsumerExecutorDescriptor.cs index 6a7795a..b7a0f8f 100644 --- a/src/DotNetCore.CAP/ConsumerExecutorDescriptor.cs +++ b/src/DotNetCore.CAP/Internal/ConsumerExecutorDescriptor.cs @@ -4,9 +4,8 @@ using System; using System.Collections.Generic; using System.Reflection; -using DotNetCore.CAP.Abstractions; -namespace DotNetCore.CAP +namespace DotNetCore.CAP.Internal { /// /// A descriptor of user definition method. diff --git a/src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs b/src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs index cb7247a..10381af 100644 --- a/src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs +++ b/src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. See License.txt in the project root for license information. using System; -using DotNetCore.CAP.Abstractions; using Microsoft.Extensions.Logging; namespace DotNetCore.CAP.Internal diff --git a/src/DotNetCore.CAP/IBootstrapper.Default.cs b/src/DotNetCore.CAP/Internal/IBootstrapper.Default.cs similarity index 95% rename from src/DotNetCore.CAP/IBootstrapper.Default.cs rename to src/DotNetCore.CAP/Internal/IBootstrapper.Default.cs index f580efa..9f09318 100644 --- a/src/DotNetCore.CAP/IBootstrapper.Default.cs +++ b/src/DotNetCore.CAP/Internal/IBootstrapper.Default.cs @@ -9,10 +9,10 @@ using DotNetCore.CAP.Persistence; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -namespace DotNetCore.CAP +namespace DotNetCore.CAP.Internal { /// - /// Default implement of . + /// Default implement of . /// internal class DefaultBootstrapper : BackgroundService, IBootstrapper { diff --git a/src/DotNetCore.CAP/IBootstrapper.cs b/src/DotNetCore.CAP/Internal/IBootstrapper.cs similarity index 93% rename from src/DotNetCore.CAP/IBootstrapper.cs rename to src/DotNetCore.CAP/Internal/IBootstrapper.cs index b781c55..67fc601 100644 --- a/src/DotNetCore.CAP/IBootstrapper.cs +++ b/src/DotNetCore.CAP/Internal/IBootstrapper.cs @@ -4,7 +4,7 @@ using System.Threading; using System.Threading.Tasks; -namespace DotNetCore.CAP +namespace DotNetCore.CAP.Internal { /// /// Represents bootstrapping logic. For example, adding initial state to the storage or querying certain entities. diff --git a/src/DotNetCore.CAP/Abstractions/CapPublisher.cs b/src/DotNetCore.CAP/Internal/ICapPublisher.Default.cs similarity index 97% rename from src/DotNetCore.CAP/Abstractions/CapPublisher.cs rename to src/DotNetCore.CAP/Internal/ICapPublisher.Default.cs index d9dd8de..e822fb6 100644 --- a/src/DotNetCore.CAP/Abstractions/CapPublisher.cs +++ b/src/DotNetCore.CAP/Internal/ICapPublisher.Default.cs @@ -7,14 +7,14 @@ using System.Diagnostics; using System.Threading; using System.Threading.Tasks; using DotNetCore.CAP.Diagnostics; -using DotNetCore.CAP.Internal; using DotNetCore.CAP.Messages; using DotNetCore.CAP.Persistence; +using DotNetCore.CAP.Transport; using Microsoft.Extensions.DependencyInjection; -namespace DotNetCore.CAP.Abstractions +namespace DotNetCore.CAP.Internal { - public class CapPublisher : ICapPublisher + internal class CapPublisher : ICapPublisher { private readonly IDispatcher _dispatcher; private readonly IDataStorage _storage; diff --git a/src/DotNetCore.CAP/IConsumerRegister.Default.cs b/src/DotNetCore.CAP/Internal/IConsumerRegister.Default.cs similarity index 99% rename from src/DotNetCore.CAP/IConsumerRegister.Default.cs rename to src/DotNetCore.CAP/Internal/IConsumerRegister.Default.cs index dd4f2ec..70e800c 100644 --- a/src/DotNetCore.CAP/IConsumerRegister.Default.cs +++ b/src/DotNetCore.CAP/Internal/IConsumerRegister.Default.cs @@ -4,19 +4,17 @@ using System; using System.Diagnostics; using System.Linq; -using System.Text; -using System.Text.Json; using System.Threading; using System.Threading.Tasks; using DotNetCore.CAP.Diagnostics; -using DotNetCore.CAP.Internal; using DotNetCore.CAP.Messages; using DotNetCore.CAP.Persistence; using DotNetCore.CAP.Serialization; +using DotNetCore.CAP.Transport; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -namespace DotNetCore.CAP +namespace DotNetCore.CAP.Internal { internal class ConsumerRegister : IConsumerRegister { diff --git a/src/DotNetCore.CAP/IConsumerRegister.cs b/src/DotNetCore.CAP/Internal/IConsumerRegister.cs similarity index 91% rename from src/DotNetCore.CAP/IConsumerRegister.cs rename to src/DotNetCore.CAP/Internal/IConsumerRegister.cs index 58b7327..1ae1323 100644 --- a/src/DotNetCore.CAP/IConsumerRegister.cs +++ b/src/DotNetCore.CAP/Internal/IConsumerRegister.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Core Community. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -namespace DotNetCore.CAP +namespace DotNetCore.CAP.Internal { /// /// Handler received message of subscribed. diff --git a/src/DotNetCore.CAP/IConsumerServiceSelector.Default.cs b/src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs similarity index 96% rename from src/DotNetCore.CAP/IConsumerServiceSelector.Default.cs rename to src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs index e7b9a56..7233980 100644 --- a/src/DotNetCore.CAP/IConsumerServiceSelector.Default.cs +++ b/src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs @@ -1,233 +1,231 @@ -// Copyright (c) .NET Core Community. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text.RegularExpressions; -using DotNetCore.CAP.Abstractions; -using Microsoft.Extensions.DependencyInjection; -using System.Collections.Concurrent; -using DotNetCore.CAP.Internal; -using Microsoft.Extensions.Options; - -namespace DotNetCore.CAP -{ - /// - /// - /// A default implementation. - /// - public class DefaultConsumerServiceSelector : IConsumerServiceSelector - { - private readonly CapOptions _capOptions; - private readonly IServiceProvider _serviceProvider; - - /// - /// since this class be designed as a Singleton service,the following two list must be thread safe! - /// - private readonly ConcurrentDictionary>> _asteriskList; - private readonly ConcurrentDictionary>> _poundList; - - /// - /// Creates a new . - /// - public DefaultConsumerServiceSelector(IServiceProvider serviceProvider) - { - _serviceProvider = serviceProvider; - _capOptions = serviceProvider.GetService>().Value; - - _asteriskList = new ConcurrentDictionary>>(); - _poundList = new ConcurrentDictionary>>(); - } - - public IReadOnlyList SelectCandidates() - { - var executorDescriptorList = new List(); - - executorDescriptorList.AddRange(FindConsumersFromInterfaceTypes(_serviceProvider)); - - executorDescriptorList.AddRange(FindConsumersFromControllerTypes()); - - return executorDescriptorList; - } - - public ConsumerExecutorDescriptor SelectBestCandidate(string key, IReadOnlyList executeDescriptor) - { - var result = MatchUsingName(key, executeDescriptor); - if (result != null) - { - return result; - } - - //[*] match with regex, i.e. foo.*.abc - result = MatchAsteriskUsingRegex(key, executeDescriptor); - if (result != null) - { - return result; - } - - //[#] match regex, i.e. foo.# - result = MatchPoundUsingRegex(key, executeDescriptor); - return result; - } - - protected virtual IEnumerable FindConsumersFromInterfaceTypes( - IServiceProvider provider) - { - var executorDescriptorList = new List(); - - var capSubscribeTypeInfo = typeof(ICapSubscribe).GetTypeInfo(); - - foreach (var service in ServiceCollectionExtensions.ServiceCollection.Where(o => o.ImplementationType != null && o.ServiceType != null)) - { - var typeInfo = service.ImplementationType.GetTypeInfo(); - if (!capSubscribeTypeInfo.IsAssignableFrom(typeInfo)) - { - continue; - } - var serviceTypeInfo = service.ServiceType.GetTypeInfo(); - - executorDescriptorList.AddRange(GetTopicAttributesDescription(typeInfo, serviceTypeInfo)); - } - - return executorDescriptorList; - } - - protected virtual IEnumerable FindConsumersFromControllerTypes() - { - var executorDescriptorList = new List(); - - var types = Assembly.GetEntryAssembly().ExportedTypes; - foreach (var type in types) - { - var typeInfo = type.GetTypeInfo(); - if (Helper.IsController(typeInfo)) - { - executorDescriptorList.AddRange(GetTopicAttributesDescription(typeInfo)); - } - } - - return executorDescriptorList; - } - - protected IEnumerable GetTopicAttributesDescription(TypeInfo typeInfo, TypeInfo serviceTypeInfo = null) - { - foreach (var method in typeInfo.DeclaredMethods) - { - var topicAttr = method.GetCustomAttributes(true); - var topicAttributes = topicAttr as IList ?? topicAttr.ToList(); - - if (!topicAttributes.Any()) - { - continue; - } - - foreach (var attr in topicAttributes) - { - if (attr.Group == null) - { - attr.Group = _capOptions.DefaultGroup + "." + _capOptions.Version; - } - else - { - attr.Group = attr.Group + "." + _capOptions.Version; - } - - var parameters = method.GetParameters() - .Select(parameter => new ParameterDescriptor - { - Name = parameter.Name, - ParameterType = parameter.ParameterType, - IsFromCap = parameter.GetCustomAttributes(typeof(FromCapAttribute)).Any() - }).ToList(); - - yield return InitDescriptor(attr, method, typeInfo, serviceTypeInfo, parameters); - } - } - } - - private static ConsumerExecutorDescriptor InitDescriptor( - TopicAttribute attr, - MethodInfo methodInfo, - TypeInfo implType, - TypeInfo serviceTypeInfo, - IList parameters) - { - var descriptor = new ConsumerExecutorDescriptor - { - Attribute = attr, - MethodInfo = methodInfo, - ImplTypeInfo = implType, - ServiceTypeInfo = serviceTypeInfo, - Parameters = parameters - }; - - return descriptor; - } - - private ConsumerExecutorDescriptor MatchUsingName(string key, IReadOnlyList executeDescriptor) - { - return executeDescriptor.FirstOrDefault(x => x.Attribute.Name == key); - } - - private ConsumerExecutorDescriptor MatchAsteriskUsingRegex(string key, IReadOnlyList executeDescriptor) - { - var group = executeDescriptor.First().Attribute.Group; - if (!_asteriskList.TryGetValue(group, out var tmpList)) - { - tmpList = executeDescriptor.Where(x => x.Attribute.Name.IndexOf('*') >= 0) - .Select(x => new RegexExecuteDescriptor - { - Name = ("^" + x.Attribute.Name + "$").Replace("*", "[0-9_a-zA-Z]+").Replace(".", "\\."), - Descriptor = x - }).ToList(); - _asteriskList.TryAdd(group, tmpList); - } - - foreach (var red in tmpList) - { - if (Regex.IsMatch(key, red.Name, RegexOptions.Singleline)) - { - return red.Descriptor; - } - } - - return null; - } - - private ConsumerExecutorDescriptor MatchPoundUsingRegex(string key, IReadOnlyList executeDescriptor) - { - var group = executeDescriptor.First().Attribute.Group; - if (!_poundList.TryGetValue(group, out var tmpList)) - { - tmpList = executeDescriptor - .Where(x => x.Attribute.Name.IndexOf('#') >= 0) - .Select(x => new RegexExecuteDescriptor - { - Name = ("^" + x.Attribute.Name.Replace(".", "\\.") + "$").Replace("#", "[0-9_a-zA-Z\\.]+"), - Descriptor = x - }).ToList(); - _poundList.TryAdd(group, tmpList); - } - - foreach (var red in tmpList) - { - if (Regex.IsMatch(key, red.Name, RegexOptions.Singleline)) - { - return red.Descriptor; - } - } - - return null; - } - - - private class RegexExecuteDescriptor - { - public string Name { get; set; } - - public T Descriptor { get; set; } - } - } -} +// Copyright (c) .NET Core Community. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text.RegularExpressions; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; + +namespace DotNetCore.CAP.Internal +{ + /// + /// + /// A default implementation. + /// + public class DefaultConsumerServiceSelector : IConsumerServiceSelector + { + private readonly CapOptions _capOptions; + private readonly IServiceProvider _serviceProvider; + + /// + /// since this class be designed as a Singleton service,the following two list must be thread safe! + /// + private readonly ConcurrentDictionary>> _asteriskList; + private readonly ConcurrentDictionary>> _poundList; + + /// + /// Creates a new . + /// + public DefaultConsumerServiceSelector(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + _capOptions = serviceProvider.GetService>().Value; + + _asteriskList = new ConcurrentDictionary>>(); + _poundList = new ConcurrentDictionary>>(); + } + + public IReadOnlyList SelectCandidates() + { + var executorDescriptorList = new List(); + + executorDescriptorList.AddRange(FindConsumersFromInterfaceTypes(_serviceProvider)); + + executorDescriptorList.AddRange(FindConsumersFromControllerTypes()); + + return executorDescriptorList; + } + + public ConsumerExecutorDescriptor SelectBestCandidate(string key, IReadOnlyList executeDescriptor) + { + var result = MatchUsingName(key, executeDescriptor); + if (result != null) + { + return result; + } + + //[*] match with regex, i.e. foo.*.abc + result = MatchAsteriskUsingRegex(key, executeDescriptor); + if (result != null) + { + return result; + } + + //[#] match regex, i.e. foo.# + result = MatchPoundUsingRegex(key, executeDescriptor); + return result; + } + + protected virtual IEnumerable FindConsumersFromInterfaceTypes( + IServiceProvider provider) + { + var executorDescriptorList = new List(); + + var capSubscribeTypeInfo = typeof(ICapSubscribe).GetTypeInfo(); + + foreach (var service in ServiceCollectionExtensions.ServiceCollection.Where(o => o.ImplementationType != null && o.ServiceType != null)) + { + var typeInfo = service.ImplementationType.GetTypeInfo(); + if (!capSubscribeTypeInfo.IsAssignableFrom(typeInfo)) + { + continue; + } + var serviceTypeInfo = service.ServiceType.GetTypeInfo(); + + executorDescriptorList.AddRange(GetTopicAttributesDescription(typeInfo, serviceTypeInfo)); + } + + return executorDescriptorList; + } + + protected virtual IEnumerable FindConsumersFromControllerTypes() + { + var executorDescriptorList = new List(); + + var types = Assembly.GetEntryAssembly().ExportedTypes; + foreach (var type in types) + { + var typeInfo = type.GetTypeInfo(); + if (Helper.IsController(typeInfo)) + { + executorDescriptorList.AddRange(GetTopicAttributesDescription(typeInfo)); + } + } + + return executorDescriptorList; + } + + protected IEnumerable GetTopicAttributesDescription(TypeInfo typeInfo, TypeInfo serviceTypeInfo = null) + { + foreach (var method in typeInfo.DeclaredMethods) + { + var topicAttr = method.GetCustomAttributes(true); + var topicAttributes = topicAttr as IList ?? topicAttr.ToList(); + + if (!topicAttributes.Any()) + { + continue; + } + + foreach (var attr in topicAttributes) + { + if (attr.Group == null) + { + attr.Group = _capOptions.DefaultGroup + "." + _capOptions.Version; + } + else + { + attr.Group = attr.Group + "." + _capOptions.Version; + } + + var parameters = method.GetParameters() + .Select(parameter => new ParameterDescriptor + { + Name = parameter.Name, + ParameterType = parameter.ParameterType, + IsFromCap = parameter.GetCustomAttributes(typeof(FromCapAttribute)).Any() + }).ToList(); + + yield return InitDescriptor(attr, method, typeInfo, serviceTypeInfo, parameters); + } + } + } + + private static ConsumerExecutorDescriptor InitDescriptor( + TopicAttribute attr, + MethodInfo methodInfo, + TypeInfo implType, + TypeInfo serviceTypeInfo, + IList parameters) + { + var descriptor = new ConsumerExecutorDescriptor + { + Attribute = attr, + MethodInfo = methodInfo, + ImplTypeInfo = implType, + ServiceTypeInfo = serviceTypeInfo, + Parameters = parameters + }; + + return descriptor; + } + + private ConsumerExecutorDescriptor MatchUsingName(string key, IReadOnlyList executeDescriptor) + { + return executeDescriptor.FirstOrDefault(x => x.Attribute.Name == key); + } + + private ConsumerExecutorDescriptor MatchAsteriskUsingRegex(string key, IReadOnlyList executeDescriptor) + { + var group = executeDescriptor.First().Attribute.Group; + if (!_asteriskList.TryGetValue(group, out var tmpList)) + { + tmpList = executeDescriptor.Where(x => x.Attribute.Name.IndexOf('*') >= 0) + .Select(x => new RegexExecuteDescriptor + { + Name = ("^" + x.Attribute.Name + "$").Replace("*", "[0-9_a-zA-Z]+").Replace(".", "\\."), + Descriptor = x + }).ToList(); + _asteriskList.TryAdd(group, tmpList); + } + + foreach (var red in tmpList) + { + if (Regex.IsMatch(key, red.Name, RegexOptions.Singleline)) + { + return red.Descriptor; + } + } + + return null; + } + + private ConsumerExecutorDescriptor MatchPoundUsingRegex(string key, IReadOnlyList executeDescriptor) + { + var group = executeDescriptor.First().Attribute.Group; + if (!_poundList.TryGetValue(group, out var tmpList)) + { + tmpList = executeDescriptor + .Where(x => x.Attribute.Name.IndexOf('#') >= 0) + .Select(x => new RegexExecuteDescriptor + { + Name = ("^" + x.Attribute.Name.Replace(".", "\\.") + "$").Replace("#", "[0-9_a-zA-Z\\.]+"), + Descriptor = x + }).ToList(); + _poundList.TryAdd(group, tmpList); + } + + foreach (var red in tmpList) + { + if (Regex.IsMatch(key, red.Name, RegexOptions.Singleline)) + { + return red.Descriptor; + } + } + + return null; + } + + + private class RegexExecuteDescriptor + { + public string Name { get; set; } + + public T Descriptor { get; set; } + } + } +} diff --git a/src/DotNetCore.CAP/IConsumerServiceSelector.cs b/src/DotNetCore.CAP/Internal/IConsumerServiceSelector.cs similarity index 97% rename from src/DotNetCore.CAP/IConsumerServiceSelector.cs rename to src/DotNetCore.CAP/Internal/IConsumerServiceSelector.cs index 555a9d7..baea9af 100644 --- a/src/DotNetCore.CAP/IConsumerServiceSelector.cs +++ b/src/DotNetCore.CAP/Internal/IConsumerServiceSelector.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; -namespace DotNetCore.CAP +namespace DotNetCore.CAP.Internal { /// /// Defines an interface for selecting an consumer service method to invoke for the current message. diff --git a/src/DotNetCore.CAP/Abstractions/IMongoTransaction.cs b/src/DotNetCore.CAP/Internal/IMongoTransaction.cs similarity index 73% rename from src/DotNetCore.CAP/Abstractions/IMongoTransaction.cs rename to src/DotNetCore.CAP/Internal/IMongoTransaction.cs index b98caf8..abb0388 100644 --- a/src/DotNetCore.CAP/Abstractions/IMongoTransaction.cs +++ b/src/DotNetCore.CAP/Internal/IMongoTransaction.cs @@ -4,7 +4,7 @@ using System; using System.Threading.Tasks; -namespace DotNetCore.CAP.Abstractions +namespace DotNetCore.CAP.Internal { public interface IMongoTransaction : IDisposable { @@ -14,8 +14,8 @@ namespace DotNetCore.CAP.Abstractions /// bool AutoCommit { get; set; } - Task BegeinAsync(bool autoCommit = true); + Task BeginAsync(bool autoCommit = true); - IMongoTransaction Begein(bool autoCommit = true); + IMongoTransaction Begin(bool autoCommit = true); } } \ No newline at end of file diff --git a/src/DotNetCore.CAP/IProcessingServer.cs b/src/DotNetCore.CAP/Internal/IProcessingServer.cs similarity index 91% rename from src/DotNetCore.CAP/IProcessingServer.cs rename to src/DotNetCore.CAP/Internal/IProcessingServer.cs index b7baa9a..8467bab 100644 --- a/src/DotNetCore.CAP/IProcessingServer.cs +++ b/src/DotNetCore.CAP/Internal/IProcessingServer.cs @@ -3,7 +3,7 @@ using System; -namespace DotNetCore.CAP +namespace DotNetCore.CAP.Internal { /// /// diff --git a/src/DotNetCore.CAP/ISubscribeExecutor.Default.cs b/src/DotNetCore.CAP/Internal/ISubscriberExecutor.Default.cs similarity index 99% rename from src/DotNetCore.CAP/ISubscribeExecutor.Default.cs rename to src/DotNetCore.CAP/Internal/ISubscriberExecutor.Default.cs index 8d2dacd..d3e91b5 100644 --- a/src/DotNetCore.CAP/ISubscribeExecutor.Default.cs +++ b/src/DotNetCore.CAP/Internal/ISubscriberExecutor.Default.cs @@ -7,15 +7,14 @@ using System.Diagnostics; using System.Threading; using System.Threading.Tasks; using DotNetCore.CAP.Diagnostics; -using DotNetCore.CAP.Internal; using DotNetCore.CAP.Messages; using DotNetCore.CAP.Persistence; using DotNetCore.CAP.Processor; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using Microsoft.Extensions.DependencyInjection; -namespace DotNetCore.CAP +namespace DotNetCore.CAP.Internal { internal class DefaultSubscriberExecutor : ISubscriberExecutor { diff --git a/src/DotNetCore.CAP/ISubscriberExecutor.cs b/src/DotNetCore.CAP/Internal/ISubscriberExecutor.cs similarity index 94% rename from src/DotNetCore.CAP/ISubscriberExecutor.cs rename to src/DotNetCore.CAP/Internal/ISubscriberExecutor.cs index b60d5f0..b1ba89b 100644 --- a/src/DotNetCore.CAP/ISubscriberExecutor.cs +++ b/src/DotNetCore.CAP/Internal/ISubscriberExecutor.cs @@ -5,7 +5,7 @@ using System.Threading; using System.Threading.Tasks; using DotNetCore.CAP.Persistence; -namespace DotNetCore.CAP +namespace DotNetCore.CAP.Internal { /// /// Consumer executor diff --git a/src/DotNetCore.CAP/Internal/LoggerExtensions.cs b/src/DotNetCore.CAP/Internal/LoggerExtensions.cs index f44cb17..025c207 100644 --- a/src/DotNetCore.CAP/Internal/LoggerExtensions.cs +++ b/src/DotNetCore.CAP/Internal/LoggerExtensions.cs @@ -5,7 +5,7 @@ using System; using System.Diagnostics.CodeAnalysis; using Microsoft.Extensions.Logging; -namespace DotNetCore.CAP +namespace DotNetCore.CAP.Internal { [SuppressMessage("ReSharper", "InconsistentNaming")] internal static class LoggerExtensions diff --git a/src/DotNetCore.CAP/Abstractions/TopicAttribute.cs b/src/DotNetCore.CAP/Internal/TopicAttribute.cs similarity index 95% rename from src/DotNetCore.CAP/Abstractions/TopicAttribute.cs rename to src/DotNetCore.CAP/Internal/TopicAttribute.cs index 6b83de4..559cd5f 100644 --- a/src/DotNetCore.CAP/Abstractions/TopicAttribute.cs +++ b/src/DotNetCore.CAP/Internal/TopicAttribute.cs @@ -3,7 +3,7 @@ using System; -namespace DotNetCore.CAP.Abstractions +namespace DotNetCore.CAP.Internal { /// /// diff --git a/src/DotNetCore.CAP/Monitoring/MessageQueryDto.cs b/src/DotNetCore.CAP/Monitoring/MessageQueryDto.cs index 39b4a56..5f4e78e 100644 --- a/src/DotNetCore.CAP/Monitoring/MessageQueryDto.cs +++ b/src/DotNetCore.CAP/Monitoring/MessageQueryDto.cs @@ -10,6 +10,7 @@ namespace DotNetCore.CAP.Monitoring public MessageType MessageType { get; set; } public string Group { get; set; } + public string Name { get; set; } public string Content { get; set; } diff --git a/src/DotNetCore.CAP/Processor/IDispatcher.Default.cs b/src/DotNetCore.CAP/Processor/IDispatcher.Default.cs index 7f1fb8c..d12f10f 100644 --- a/src/DotNetCore.CAP/Processor/IDispatcher.Default.cs +++ b/src/DotNetCore.CAP/Processor/IDispatcher.Default.cs @@ -7,6 +7,7 @@ using System.Threading; using System.Threading.Tasks; using DotNetCore.CAP.Internal; using DotNetCore.CAP.Persistence; +using DotNetCore.CAP.Transport; using Microsoft.Extensions.Logging; namespace DotNetCore.CAP.Processor diff --git a/src/DotNetCore.CAP/Processor/IProcessingServer.Cap.cs b/src/DotNetCore.CAP/Processor/IProcessingServer.Cap.cs index e00128b..d864c7d 100644 --- a/src/DotNetCore.CAP/Processor/IProcessingServer.Cap.cs +++ b/src/DotNetCore.CAP/Processor/IProcessingServer.Cap.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; +using DotNetCore.CAP.Internal; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; diff --git a/src/DotNetCore.CAP/Processor/IProcessor.TransportCheck.cs b/src/DotNetCore.CAP/Processor/IProcessor.TransportCheck.cs index d0f4829..3a1c26a 100644 --- a/src/DotNetCore.CAP/Processor/IProcessor.TransportCheck.cs +++ b/src/DotNetCore.CAP/Processor/IProcessor.TransportCheck.cs @@ -3,6 +3,7 @@ using System; using System.Threading.Tasks; +using DotNetCore.CAP.Internal; namespace DotNetCore.CAP.Processor { diff --git a/src/DotNetCore.CAP/IConsumerClient.cs b/src/DotNetCore.CAP/Transport/IConsumerClient.cs similarity index 97% rename from src/DotNetCore.CAP/IConsumerClient.cs rename to src/DotNetCore.CAP/Transport/IConsumerClient.cs index b918fc8..e74b247 100644 --- a/src/DotNetCore.CAP/IConsumerClient.cs +++ b/src/DotNetCore.CAP/Transport/IConsumerClient.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Threading; using DotNetCore.CAP.Messages; -namespace DotNetCore.CAP +namespace DotNetCore.CAP.Transport { /// /// diff --git a/src/DotNetCore.CAP/IConsumerClientFactory.cs b/src/DotNetCore.CAP/Transport/IConsumerClientFactory.cs similarity index 93% rename from src/DotNetCore.CAP/IConsumerClientFactory.cs rename to src/DotNetCore.CAP/Transport/IConsumerClientFactory.cs index a5ce33f..7d7cb22 100644 --- a/src/DotNetCore.CAP/IConsumerClientFactory.cs +++ b/src/DotNetCore.CAP/Transport/IConsumerClientFactory.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Core Community. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -namespace DotNetCore.CAP +namespace DotNetCore.CAP.Transport { /// /// Consumer client factory to create consumer client instance. diff --git a/src/DotNetCore.CAP/IDispatcher.cs b/src/DotNetCore.CAP/Transport/IDispatcher.cs similarity index 85% rename from src/DotNetCore.CAP/IDispatcher.cs rename to src/DotNetCore.CAP/Transport/IDispatcher.cs index bc47c02..da660d5 100644 --- a/src/DotNetCore.CAP/IDispatcher.cs +++ b/src/DotNetCore.CAP/Transport/IDispatcher.cs @@ -1,9 +1,10 @@ // Copyright (c) .NET Core Community. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. +using DotNetCore.CAP.Internal; using DotNetCore.CAP.Persistence; -namespace DotNetCore.CAP +namespace DotNetCore.CAP.Transport { public interface IDispatcher { diff --git a/src/DotNetCore.CAP/MqLogType.cs b/src/DotNetCore.CAP/Transport/MqLogType.cs similarity index 94% rename from src/DotNetCore.CAP/MqLogType.cs rename to src/DotNetCore.CAP/Transport/MqLogType.cs index 94c21c0..3412b3a 100644 --- a/src/DotNetCore.CAP/MqLogType.cs +++ b/src/DotNetCore.CAP/Transport/MqLogType.cs @@ -3,7 +3,7 @@ using System; -namespace DotNetCore.CAP +namespace DotNetCore.CAP.Transport { public enum MqLogType { diff --git a/test/DotNetCore.CAP.Test/ModelBinderFactoryTest.cs b/test/DotNetCore.CAP.Test/ModelBinderFactoryTest.cs deleted file mode 100644 index 3006afa..0000000 --- a/test/DotNetCore.CAP.Test/ModelBinderFactoryTest.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Linq; -using System.Reflection; -using DotNetCore.CAP.Abstractions; -using DotNetCore.CAP.Internal; -using Moq; -using Xunit; - -namespace DotNetCore.CAP.Test -{ - public class ModelBinderFactoryTest - { - private IModelBinderFactory _factory; - - public ModelBinderFactoryTest() - { - var serializer = Mock.Of(); - _factory = new ModelBinderFactory(serializer); - } - - [Theory] - [InlineData(nameof(Sample.DateTimeParam))] - [InlineData(nameof(Sample.StringParam))] - [InlineData(nameof(Sample.IntegerParam))] - [InlineData(nameof(Sample.GuidParam))] - [InlineData(nameof(Sample.UriParam))] - public void CreateSimpleTypeBinderTest(string methodName) - { - var methodInfo = typeof(Sample).GetRuntimeMethods().Single(x => x.Name == methodName); - var binder = _factory.CreateBinder(methodInfo.GetParameters()[0]); - Assert.NotNull(binder); - Assert.True(binder is SimpleTypeModelBinder); - Assert.False(binder is ComplexTypeModelBinder); - } - - [Theory] - [InlineData(nameof(Sample.ComplexTypeParam))] - public void CreateComplexTypeBinderTest(string methodName) - { - var methodInfo = typeof(Sample).GetRuntimeMethods().Single(x => x.Name == methodName); - var binder = _factory.CreateBinder(methodInfo.GetParameters()[0]); - Assert.NotNull(binder); - Assert.False(binder is SimpleTypeModelBinder); - Assert.True(binder is ComplexTypeModelBinder); - } - } -} \ No newline at end of file diff --git a/test/DotNetCore.CAP.Test/SnowflakeIdTest.cs b/test/DotNetCore.CAP.Test/SnowflakeIdTest.cs index 46553cf..5345168 100644 --- a/test/DotNetCore.CAP.Test/SnowflakeIdTest.cs +++ b/test/DotNetCore.CAP.Test/SnowflakeIdTest.cs @@ -1,6 +1,6 @@ using System.Linq; using System.Threading.Tasks; -using DotNetCore.CAP.Infrastructure; +using DotNetCore.CAP.Internal; using Xunit; namespace DotNetCore.CAP.Test