Browse Source

Fix the exception that the consumer name is null.

master
Savorboard 3 years ago
parent
commit
27d4bb7cef
4 changed files with 41 additions and 61 deletions
  1. +0
    -25
      .dockerignore
  2. +2
    -2
      build/version.props
  3. +33
    -33
      src/DotNetCore.CAP/CAP.Attribute.cs
  4. +6
    -1
      src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs

+ 0
- 25
.dockerignore View File

@@ -1,25 +0,0 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

+ 2
- 2
build/version.props View File

@@ -1,8 +1,8 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<VersionMajor>5</VersionMajor> <VersionMajor>5</VersionMajor>
<VersionMinor>1</VersionMinor>
<VersionPatch>4</VersionPatch>
<VersionMinor>2</VersionMinor>
<VersionPatch>0</VersionPatch>
<VersionQuality></VersionQuality> <VersionQuality></VersionQuality>
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix> <VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
</PropertyGroup> </PropertyGroup>


+ 33
- 33
src/DotNetCore.CAP/CAP.Attribute.cs View File

@@ -1,39 +1,39 @@
// 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.Collections.ObjectModel;
using DotNetCore.CAP.Internal;
// ReSharper disable once CheckNamespace
namespace DotNetCore.CAP
{
public class CapSubscribeAttribute : TopicAttribute
// 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.Collections.ObjectModel;
using DotNetCore.CAP.Internal;
// ReSharper disable once CheckNamespace
namespace DotNetCore.CAP
{
public class CapSubscribeAttribute : TopicAttribute
{ {
public CapSubscribeAttribute(string name, bool isPartial = false)
: base(name, isPartial)
public CapSubscribeAttribute(string name, bool isPartial = false)
: base(name, isPartial)
{ {
} }
public override string ToString()
{
return Name;
}
}
[AttributeUsage(AttributeTargets.Parameter)]
public class FromCapAttribute : Attribute
{
}
public class CapHeader : ReadOnlyDictionary<string, string>
{
public CapHeader(IDictionary<string, string> dictionary) : base(dictionary)
{
}
}
public override string ToString()
{
return Name;
}
}
[AttributeUsage(AttributeTargets.Parameter)]
public class FromCapAttribute : Attribute
{
}
public class CapHeader : ReadOnlyDictionary<string, string>
{
public CapHeader(IDictionary<string, string> dictionary) : base(dictionary)
{
}
}
} }

+ 6
- 1
src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs View File

@@ -131,7 +131,7 @@ namespace DotNetCore.CAP.Internal
// Ignore partial attributes when no topic attribute is defined on class. // Ignore partial attributes when no topic attribute is defined on class.
if (topicClassAttribute is null) if (topicClassAttribute is null)
{ {
topicMethodAttributes = topicMethodAttributes.Where(x => !x.IsPartial);
topicMethodAttributes = topicMethodAttributes.Where(x => !x.IsPartial && x.Name != null);
} }


if (!topicMethodAttributes.Any()) if (!topicMethodAttributes.Any())
@@ -189,6 +189,11 @@ namespace DotNetCore.CAP.Internal


private ConsumerExecutorDescriptor MatchUsingName(string key, IReadOnlyList<ConsumerExecutorDescriptor> executeDescriptor) private ConsumerExecutorDescriptor MatchUsingName(string key, IReadOnlyList<ConsumerExecutorDescriptor> executeDescriptor)
{ {
if (key == null)
{
throw new ArgumentNullException(nameof(key));
}

return executeDescriptor.FirstOrDefault(x => x.TopicName.Equals(key, StringComparison.InvariantCultureIgnoreCase)); return executeDescriptor.FirstOrDefault(x => x.TopicName.Equals(key, StringComparison.InvariantCultureIgnoreCase));
} }




Loading…
Cancel
Save