Skip to content

Commit 0a39601

Browse files
authored
Add QueueAttribute.Default (#1055)
1 parent 06c3735 commit 0a39601

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Source/EasyNetQ/Conventions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public Conventions(ITypeNameSerializer typeNameSerializer)
8181

8282
private QueueAttribute GetQueueAttribute(Type messageType)
8383
{
84-
return messageType.GetAttribute<QueueAttribute>() ?? new QueueAttribute(string.Empty);
84+
return messageType.GetAttribute<QueueAttribute>() ?? QueueAttribute.Default;
8585
}
8686

8787
public ExchangeNameConvention ExchangeNamingConvention { get; set; }
@@ -97,4 +97,4 @@ private QueueAttribute GetQueueAttribute(Type messageType)
9797

9898
public ConsumerTagConvention ConsumerTagConvention { get; set; }
9999
}
100-
}
100+
}

Source/EasyNetQ/QueueAttribute.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ namespace EasyNetQ
55
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple=false)]
66
public class QueueAttribute : Attribute
77
{
8+
internal static readonly QueueAttribute Default = new QueueAttribute(null);
9+
810
public QueueAttribute(string queueName)
911
{
1012
QueueName = queueName ?? string.Empty;
1113
}
1214

1315
public string QueueName { get; }
16+
1417
public string ExchangeName { get; set; }
1518
}
1619
}

Source/EasyNetQ/ReflectionHelpers.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
using System.Collections.Concurrent;
33
using System.Collections.Generic;
44
using System.Linq;
5-
using System.Linq.Expressions;
6-
using System.Reflection;
7-
85

96
namespace EasyNetQ
107
{
@@ -14,7 +11,7 @@ public static class ReflectionHelpers
1411

1512
private static Dictionary<Type, Attribute[]> GetOrAddTypeAttributeDictionary(Type type)
1613
{
17-
return typesAttributes.GetOrAdd(type, t => t.GetTypeInfo().GetCustomAttributes(true)
14+
return typesAttributes.GetOrAdd(type, t => t.GetCustomAttributes(true)
1815
.Cast<Attribute>()
1916
.GroupBy(attr => attr.GetType())
2017
.ToDictionary(group => group.Key, group => group.ToArray()));
@@ -36,7 +33,7 @@ public static TAttribute GetAttribute<TAttribute>(this Type type) where TAttribu
3633
{
3734
return (TAttribute)attributes[0];
3835
}
39-
return default(TAttribute);
36+
return default;
4037
}
4138
}
42-
}
39+
}

0 commit comments

Comments
 (0)