11
11
/// </summary>
12
12
public static class MessageConventionExtensions
13
13
{
14
+ static byte [ ] nsbPublicKeyToken ;
15
+
16
+ static MessageConventionExtensions ( )
17
+ {
18
+ var currentAssemblyName = typeof ( MessageConventionExtensions ) . Assembly . GetName ( ) ;
19
+ nsbPublicKeyToken = currentAssemblyName . GetPublicKeyToken ( ) ;
20
+ }
21
+
22
+ internal static bool IsFromParticularAssembly ( Type type )
23
+ {
24
+ return type . Assembly . GetName ( )
25
+ . GetPublicKeyToken ( )
26
+ . SequenceEqual ( nsbPublicKeyToken ) ;
27
+ }
28
+
14
29
/// <summary>
15
30
/// Returns true if the given object is a message.
16
31
/// </summary>
@@ -27,10 +42,20 @@ public static bool IsMessageType(Type t)
27
42
try
28
43
{
29
44
return MessagesConventionCache . ApplyConvention ( t ,
30
- type => IsMessageTypeAction ( type ) ||
31
- IsCommandTypeAction ( type ) ||
32
- IsEventTypeAction ( type ) ||
33
- IsInSystemConventionList ( type ) ) ;
45
+ type =>
46
+ {
47
+ if ( IsInSystemConventionList ( type ) )
48
+ {
49
+ return true ;
50
+ }
51
+ if ( IsFromParticularAssembly ( type ) )
52
+ {
53
+ return false ;
54
+ }
55
+ return IsMessageTypeAction ( type ) ||
56
+ IsCommandTypeAction ( type ) ||
57
+ IsEventTypeAction ( type ) ;
58
+ } ) ;
34
59
}
35
60
catch ( Exception ex )
36
61
{
@@ -73,7 +98,14 @@ public static bool IsCommandType(Type t)
73
98
{
74
99
try
75
100
{
76
- return CommandsConventionCache . ApplyConvention ( t , type => IsCommandTypeAction ( type ) ) ;
101
+ return CommandsConventionCache . ApplyConvention ( t , type =>
102
+ {
103
+ if ( IsFromParticularAssembly ( type ) )
104
+ {
105
+ return false ;
106
+ }
107
+ return IsCommandTypeAction ( type ) ;
108
+ } ) ;
77
109
}
78
110
catch ( Exception ex )
79
111
{
@@ -96,7 +128,14 @@ public static bool IsExpressMessageType(Type t)
96
128
{
97
129
try
98
130
{
99
- return ExpressConventionCache . ApplyConvention ( t , type => IsExpressMessageAction ( type ) ) ;
131
+ return ExpressConventionCache . ApplyConvention ( t , type =>
132
+ {
133
+ if ( IsFromParticularAssembly ( type ) )
134
+ {
135
+ return false ;
136
+ }
137
+ return IsExpressMessageAction ( type ) ;
138
+ } ) ;
100
139
}
101
140
catch ( Exception ex )
102
141
{
@@ -151,7 +190,14 @@ public static bool IsEventType(Type t)
151
190
{
152
191
try
153
192
{
154
- return EventsConventionCache . ApplyConvention ( t , type => IsEventTypeAction ( type ) ) ;
193
+ return EventsConventionCache . ApplyConvention ( t , type =>
194
+ {
195
+ if ( IsFromParticularAssembly ( type ) )
196
+ {
197
+ return false ;
198
+ }
199
+ return IsEventTypeAction ( type ) ;
200
+ } ) ;
155
201
}
156
202
catch ( Exception ex )
157
203
{
0 commit comments