@@ -3,16 +3,30 @@ using DotNetCore.CAP.Infrastructure; | |||||
namespace DotNetCore.CAP.Abstractions | namespace DotNetCore.CAP.Abstractions | ||||
{ | { | ||||
/// <summary> | |||||
/// A context for consumers, it used to be provider wapper of method description and received message. | |||||
/// </summary> | |||||
public class ConsumerContext | public class ConsumerContext | ||||
{ | { | ||||
/// <summary> | |||||
/// create a new instance of <see cref="ConsumerContext"/> . | |||||
/// </summary> | |||||
/// <param name="descriptor">consumer method descriptor. </param> | |||||
/// <param name="message"> reveied message.</param> | |||||
public ConsumerContext(ConsumerExecutorDescriptor descriptor, DeliverMessage message) | public ConsumerContext(ConsumerExecutorDescriptor descriptor, DeliverMessage message) | ||||
{ | { | ||||
ConsumerDescriptor = descriptor ?? throw new ArgumentNullException(nameof(descriptor)); | ConsumerDescriptor = descriptor ?? throw new ArgumentNullException(nameof(descriptor)); | ||||
DeliverMessage = message ?? throw new ArgumentNullException(nameof(message)); | DeliverMessage = message ?? throw new ArgumentNullException(nameof(message)); | ||||
} | } | ||||
/// <summary> | |||||
/// a descriptor of consumer information need to be performed. | |||||
/// </summary> | |||||
public ConsumerExecutorDescriptor ConsumerDescriptor { get; set; } | public ConsumerExecutorDescriptor ConsumerDescriptor { get; set; } | ||||
/// <summary> | |||||
/// consumer reveived message. | |||||
/// </summary> | |||||
public DeliverMessage DeliverMessage { get; set; } | public DeliverMessage DeliverMessage { get; set; } | ||||
} | } | ||||
} | } |
@@ -2,6 +2,9 @@ | |||||
namespace DotNetCore.CAP.Abstractions | namespace DotNetCore.CAP.Abstractions | ||||
{ | { | ||||
/// <summary> | |||||
/// A descriptor of user definition method. | |||||
/// </summary> | |||||
public class ConsumerExecutorDescriptor | public class ConsumerExecutorDescriptor | ||||
{ | { | ||||
public MethodInfo MethodInfo { get; set; } | public MethodInfo MethodInfo { get; set; } | ||||
@@ -2,6 +2,9 @@ | |||||
namespace DotNetCore.CAP.Abstractions | namespace DotNetCore.CAP.Abstractions | ||||
{ | { | ||||
/// <summary> | |||||
/// a context of consumer invoker. | |||||
/// </summary> | |||||
public class ConsumerInvokerContext | public class ConsumerInvokerContext | ||||
{ | { | ||||
public ConsumerInvokerContext(ConsumerContext consumerContext) | public ConsumerInvokerContext(ConsumerContext consumerContext) | ||||
@@ -2,8 +2,14 @@ | |||||
namespace DotNetCore.CAP.Abstractions | namespace DotNetCore.CAP.Abstractions | ||||
{ | { | ||||
/// <summary> | |||||
/// Perform user definition method of consumers. | |||||
/// </summary> | |||||
public interface IConsumerInvoker | public interface IConsumerInvoker | ||||
{ | { | ||||
/// <summary> | |||||
/// begin to invoke method. | |||||
/// </summary> | |||||
Task InvokeAsync(); | Task InvokeAsync(); | ||||
} | } | ||||
} | } |
@@ -2,8 +2,28 @@ | |||||
namespace DotNetCore.CAP.Abstractions.ModelBinding | namespace DotNetCore.CAP.Abstractions.ModelBinding | ||||
{ | { | ||||
/// <summary> | |||||
/// Defines an interface for model binders. | |||||
/// </summary> | |||||
public interface IModelBinder | public interface IModelBinder | ||||
{ | { | ||||
/// <summary> | |||||
/// Attempts to bind a model. | |||||
/// </summary> | |||||
/// <param name="bindingContext">The <see cref="ModelBindingContext"/>.</param> | |||||
/// <returns> | |||||
/// <para> | |||||
/// A <see cref="Task"/> which will complete when the model binding process completes. | |||||
/// </para> | |||||
/// <para> | |||||
/// If model binding was successful, the <see cref="ModelBindingContext.Result"/> should have | |||||
/// <see cref="ModelBindingResult.IsModelSet"/> set to <c>true</c>. | |||||
/// </para> | |||||
/// <para> | |||||
/// A model binder that completes successfully should set <see cref="ModelBindingContext.Result"/> to | |||||
/// a value returned from <see cref="ModelBindingResult.Success"/>. | |||||
/// </para> | |||||
/// </returns> | |||||
Task BindModelAsync(ModelBindingContext bindingContext); | Task BindModelAsync(ModelBindingContext bindingContext); | ||||
} | } | ||||
} | } |
@@ -3,18 +3,45 @@ using Microsoft.Extensions.Primitives; | |||||
namespace DotNetCore.CAP.Abstractions.ModelBinding | namespace DotNetCore.CAP.Abstractions.ModelBinding | ||||
{ | { | ||||
// <summary> | |||||
/// A context that contains operating information for model binding and validation. | |||||
/// </summary> | |||||
public class ModelBindingContext | public class ModelBindingContext | ||||
{ | { | ||||
/// <summary> | |||||
/// Gets or sets the model value for the current operation. | |||||
/// </summary> | |||||
/// <remarks> | |||||
/// The <see cref="Model"/> will typically be set for a binding operation that works | |||||
/// against a pre-existing model object to update certain properties. | |||||
/// </remarks> | |||||
public object Model { get; set; } | public object Model { get; set; } | ||||
/// <summary> | |||||
/// Gets or sets the name of the model. | |||||
/// </summary> | |||||
public string ModelName { get; set; } | public string ModelName { get; set; } | ||||
/// <summary> | |||||
/// Gets or sets the type of the model. | |||||
/// </summary> | |||||
public Type ModelType { get; set; } | public Type ModelType { get; set; } | ||||
/// <summary> | |||||
/// Gets or sets the values of the model. | |||||
/// </summary> | |||||
public StringValues Values { get; set; } | public StringValues Values { get; set; } | ||||
/// <summary> | |||||
/// <para> | |||||
/// Gets or sets a result which represents the result of the model binding process. | |||||
/// </para> | |||||
/// </summary> | |||||
public object Result { get; set; } | public object Result { get; set; } | ||||
/// <summary> | |||||
/// Creates a new <see cref="ModelBindingContext"/> for top-level model binding operation. | |||||
/// </summary> | |||||
public static ModelBindingContext CreateBindingContext(string values, string modelName, Type modelType) | public static ModelBindingContext CreateBindingContext(string values, string modelName, Type modelType) | ||||
{ | { | ||||
return new ModelBindingContext() | return new ModelBindingContext() | ||||
@@ -2,6 +2,9 @@ | |||||
namespace DotNetCore.CAP.Abstractions | namespace DotNetCore.CAP.Abstractions | ||||
{ | { | ||||
/// <summary> | |||||
/// An abstract attribute that for kafka attribute or rabbitmq attribute | |||||
/// </summary> | |||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true)] | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true)] | ||||
public abstract class TopicAttribute : Attribute | public abstract class TopicAttribute : Attribute | ||||
{ | { | ||||
@@ -12,11 +15,17 @@ namespace DotNetCore.CAP.Abstractions | |||||
this._name = topicName; | this._name = topicName; | ||||
} | } | ||||
/// <summary> | |||||
/// topic or exchange route key name. | |||||
/// </summary> | |||||
public string Name | public string Name | ||||
{ | { | ||||
get { return _name; } | get { return _name; } | ||||
} | } | ||||
/// <summary> | |||||
/// the consumer group. | |||||
/// </summary> | |||||
public string GroupOrExchange { get; set; } | public string GroupOrExchange { get; set; } | ||||
public bool IsOneWay { get; set; } | public bool IsOneWay { get; set; } | ||||
@@ -49,7 +49,7 @@ namespace Microsoft.Extensions.DependencyInjection | |||||
return AddSingleton<IJob, T>(); | return AddSingleton<IJob, T>(); | ||||
} | } | ||||
public virtual CapBuilder AddProducerClient<T>() | |||||
public virtual CapBuilder AddProducerService<T>() | |||||
where T : class, ICapProducerService | where T : class, ICapProducerService | ||||
{ | { | ||||
return AddScoped(typeof(ICapProducerService), typeof(T)); | return AddScoped(typeof(ICapProducerService), typeof(T)); | ||||
@@ -19,7 +19,7 @@ | |||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="1.1.2" /> | <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="1.1.2" /> | ||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="1.1.1" /> | <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="1.1.1" /> | ||||
<PackageReference Include="ncrontab" Version="3.3.0" /> | <PackageReference Include="ncrontab" Version="3.3.0" /> | ||||
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" /> | |||||
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" /> | |||||
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" /> | <PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" /> | ||||
</ItemGroup> | </ItemGroup> | ||||