@@ -32,19 +32,19 @@ public static IServiceCollection AddMqttControllers(this IServiceCollection serv
32
32
{
33
33
return services . AddMqttControllers ( opt => { } ) ;
34
34
}
35
- public static IServiceCollection AddMqttControllers ( this IServiceCollection services , Action < MqttRoutingOptions > _options )
35
+ public static IServiceCollection AddMqttControllers ( this IServiceCollection services , Action < MqttRoutingOptions > _options )
36
36
{
37
37
var _opt = new MqttRoutingOptions ( ) ;
38
38
_opt . WithJsonSerializerOptions ( ) ;
39
39
_opt . FromAssemblies = null ;
40
40
_opt . RouteInvocationInterceptor = null ;
41
- _options ? . Invoke ( _opt ) ;
42
-
41
+ _options ? . Invoke ( _opt ) ;
42
+
43
43
services . AddSingleton ( _opt ) ;
44
44
services . AddSingleton ( _ =>
45
45
{
46
-
47
- var fromAssemblies = _opt . FromAssemblies ;
46
+
47
+ var fromAssemblies = _opt . FromAssemblies ;
48
48
if ( fromAssemblies != null && fromAssemblies . Length == 0 )
49
49
{
50
50
throw new ArgumentException ( "'fromAssemblies' cannot be an empty array. Pass null or a collection of 1 or more assemblies." , nameof ( fromAssemblies ) ) ;
@@ -58,7 +58,7 @@ public static IServiceCollection AddMqttControllers(this IServiceCollection serv
58
58
services . AddSingleton < MqttRouter > ( ) ;
59
59
if ( _opt . RouteInvocationInterceptor != null )
60
60
{
61
- services . AddSingleton ( typeof ( IRouteInvocationInterceptor ) , _opt . RouteInvocationInterceptor ) ;
61
+ services . AddSingleton ( typeof ( IRouteInvocationInterceptor ) , _opt . RouteInvocationInterceptor ) ;
62
62
}
63
63
return services ;
64
64
}
@@ -103,10 +103,17 @@ public static IApplicationBuilder UseAttributeRouting(this IApplicationBuilder a
103
103
{
104
104
try
105
105
{
106
- await interceptor ? . RouteExecuting ( args . ClientId , args . ApplicationMessage ) ;
106
+ if ( interceptor != null )
107
+ {
108
+ await interceptor ? . RouteExecuting ( args . ClientId , args . ApplicationMessage ) ;
109
+ }
110
+
107
111
await router . OnIncomingApplicationMessage ( app . ApplicationServices , args , allowUnmatchedRoutes ) ;
108
- await interceptor ? . RouteExecuted ( args , null ) ;
109
112
113
+ if ( interceptor != null )
114
+ {
115
+ await interceptor ? . RouteExecuted ( args , null ) ;
116
+ }
110
117
}
111
118
catch ( Exception ex )
112
119
{
0 commit comments