Browse Source

Add comments.

master
yangxiaodong 7 years ago
parent
commit
00f4225328
9 changed files with 84 additions and 2 deletions
  1. +14
    -0
      src/DotNetCore.CAP/Abstractions/ConsumerContext.cs
  2. +3
    -0
      src/DotNetCore.CAP/Abstractions/ConsumerExecutorDescriptor.cs
  3. +3
    -0
      src/DotNetCore.CAP/Abstractions/ConsumerInvokerContext.cs
  4. +6
    -0
      src/DotNetCore.CAP/Abstractions/IConsumerInvoker.cs
  5. +20
    -0
      src/DotNetCore.CAP/Abstractions/ModelBinding/IModelBinder.cs
  6. +27
    -0
      src/DotNetCore.CAP/Abstractions/ModelBinding/ModelBindingContext.cs
  7. +9
    -0
      src/DotNetCore.CAP/Abstractions/TopicAttribute.cs
  8. +1
    -1
      src/DotNetCore.CAP/CAP.Builder.cs
  9. +1
    -1
      src/DotNetCore.CAP/DotNetCore.CAP.csproj

+ 14
- 0
src/DotNetCore.CAP/Abstractions/ConsumerContext.cs View File

@@ -3,16 +3,30 @@ using DotNetCore.CAP.Infrastructure;

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
{
/// <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)
{
ConsumerDescriptor = descriptor ?? throw new ArgumentNullException(nameof(descriptor));
DeliverMessage = message ?? throw new ArgumentNullException(nameof(message));
}

/// <summary>
/// a descriptor of consumer information need to be performed.
/// </summary>
public ConsumerExecutorDescriptor ConsumerDescriptor { get; set; }

/// <summary>
/// consumer reveived message.
/// </summary>
public DeliverMessage DeliverMessage { get; set; }
}
}

+ 3
- 0
src/DotNetCore.CAP/Abstractions/ConsumerExecutorDescriptor.cs View File

@@ -2,6 +2,9 @@

namespace DotNetCore.CAP.Abstractions
{
/// <summary>
/// A descriptor of user definition method.
/// </summary>
public class ConsumerExecutorDescriptor
{
public MethodInfo MethodInfo { get; set; }


+ 3
- 0
src/DotNetCore.CAP/Abstractions/ConsumerInvokerContext.cs View File

@@ -2,6 +2,9 @@

namespace DotNetCore.CAP.Abstractions
{
/// <summary>
/// a context of consumer invoker.
/// </summary>
public class ConsumerInvokerContext
{
public ConsumerInvokerContext(ConsumerContext consumerContext)


+ 6
- 0
src/DotNetCore.CAP/Abstractions/IConsumerInvoker.cs View File

@@ -2,8 +2,14 @@

namespace DotNetCore.CAP.Abstractions
{
/// <summary>
/// Perform user definition method of consumers.
/// </summary>
public interface IConsumerInvoker
{
/// <summary>
/// begin to invoke method.
/// </summary>
Task InvokeAsync();
}
}

+ 20
- 0
src/DotNetCore.CAP/Abstractions/ModelBinding/IModelBinder.cs View File

@@ -2,8 +2,28 @@

namespace DotNetCore.CAP.Abstractions.ModelBinding
{
/// <summary>
/// Defines an interface for model binders.
/// </summary>
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);
}
}

+ 27
- 0
src/DotNetCore.CAP/Abstractions/ModelBinding/ModelBindingContext.cs View File

@@ -3,18 +3,45 @@ using Microsoft.Extensions.Primitives;

namespace DotNetCore.CAP.Abstractions.ModelBinding
{
// <summary>
/// A context that contains operating information for model binding and validation.
/// </summary>
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; }

/// <summary>
/// Gets or sets the name of the model.
/// </summary>
public string ModelName { get; set; }

/// <summary>
/// Gets or sets the type of the model.
/// </summary>
public Type ModelType { get; set; }

/// <summary>
/// Gets or sets the values of the model.
/// </summary>
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; }

/// <summary>
/// Creates a new <see cref="ModelBindingContext"/> for top-level model binding operation.
/// </summary>
public static ModelBindingContext CreateBindingContext(string values, string modelName, Type modelType)
{
return new ModelBindingContext()


+ 9
- 0
src/DotNetCore.CAP/Abstractions/TopicAttribute.cs View File

@@ -2,6 +2,9 @@

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)]
public abstract class TopicAttribute : Attribute
{
@@ -12,11 +15,17 @@ namespace DotNetCore.CAP.Abstractions
this._name = topicName;
}

/// <summary>
/// topic or exchange route key name.
/// </summary>
public string Name
{
get { return _name; }
}

/// <summary>
/// the consumer group.
/// </summary>
public string GroupOrExchange { get; set; }

public bool IsOneWay { get; set; }


+ 1
- 1
src/DotNetCore.CAP/CAP.Builder.cs View File

@@ -49,7 +49,7 @@ namespace Microsoft.Extensions.DependencyInjection
return AddSingleton<IJob, T>();
}

public virtual CapBuilder AddProducerClient<T>()
public virtual CapBuilder AddProducerService<T>()
where T : class, ICapProducerService
{
return AddScoped(typeof(ICapProducerService), typeof(T));


+ 1
- 1
src/DotNetCore.CAP/DotNetCore.CAP.csproj View File

@@ -19,7 +19,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="1.1.1" />
<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" />
</ItemGroup>



Loading…
Cancel
Save