13
13
using Tapeti . Default ;
14
14
using Tapeti . Ninject ;
15
15
using Tapeti . SimpleInjector ;
16
- using Tapeti . UnityContainer ;
17
- using Unity ;
18
16
using Container = SimpleInjector . Container ;
19
17
20
18
// ReSharper disable UnusedMember.Global
@@ -23,14 +21,13 @@ namespace _01_PublishSubscribe
23
21
{
24
22
public class Program
25
23
{
26
- public static void Main ( string [ ] args )
24
+ public static void Main ( )
27
25
{
28
26
var dependencyResolver = GetSimpleInjectorDependencyResolver ( ) ;
29
27
30
28
// or use your IoC container of choice:
31
29
//var dependencyResolver = GetAutofacDependencyResolver();
32
30
//var dependencyResolver = GetCastleWindsorDependencyResolver();
33
- //var dependencyResolver = GetUnityDependencyResolver();
34
31
//var dependencyResolver = GetNinjectDependencyResolver();
35
32
36
33
// This helper is used because this example is not run as a service. You do not
@@ -47,7 +44,7 @@ internal static async Task MainAsync(IDependencyResolver dependencyResolver, Fun
47
44
. RegisterAllControllers ( )
48
45
. Build ( ) ;
49
46
50
- using ( var connection = new TapetiConnection ( config )
47
+ await using var connection = new TapetiConnection ( config )
51
48
{
52
49
// Params is optional if you want to use the defaults, but we'll set it
53
50
// explicitly for this example
@@ -63,28 +60,27 @@ internal static async Task MainAsync(IDependencyResolver dependencyResolver, Fun
63
60
{ "example" , "01 - Publish Subscribe" }
64
61
}
65
62
}
66
- } )
67
- {
68
- // IoC containers that separate the builder from the resolver (Autofac) must be built after
69
- // creating a TapetConnection, as it modifies the container by injecting IPublisher.
70
- ( dependencyResolver as AutofacDependencyResolver ) ? . Build ( ) ;
63
+ } ;
64
+
65
+ // IoC containers that separate the builder from the resolver (Autofac) must be built after
66
+ // creating a TapetConnection, as it modifies the container by injecting IPublisher.
67
+ ( dependencyResolver as AutofacDependencyResolver ) ? . Build ( ) ;
71
68
72
69
73
- // Create the queues and start consuming immediately.
74
- // If you need to do some processing before processing messages, but after the
75
- // queues have initialized, pass false as the startConsuming parameter and store
76
- // the returned ISubscriber. Then call Resume on it later.
77
- await connection . Subscribe ( ) ;
70
+ // Create the queues and start consuming immediately.
71
+ // If you need to do some processing before processing messages, but after the
72
+ // queues have initialized, pass false as the startConsuming parameter and store
73
+ // the returned ISubscriber. Then call Resume on it later.
74
+ await connection . Subscribe ( ) ;
78
75
79
76
80
- // We could get an IPublisher from the container directly, but since you'll usually use
81
- // it as an injected constructor parameter this shows
82
- await dependencyResolver . Resolve < ExamplePublisher > ( ) . SendTestMessage ( ) ;
77
+ // We could get an IPublisher from the container directly, but since you'll usually use
78
+ // it as an injected constructor parameter this shows
79
+ await dependencyResolver . Resolve < ExamplePublisher > ( ) . SendTestMessage ( ) ;
83
80
84
81
85
- // Wait for the controller to signal that the message has been received
86
- await waitForDone ( ) ;
87
- }
82
+ // Wait for the controller to signal that the message has been received
83
+ await waitForDone ( ) ;
88
84
}
89
85
90
86
@@ -132,17 +128,6 @@ internal static IDependencyContainer GetCastleWindsorDependencyResolver()
132
128
}
133
129
134
130
135
- internal static IDependencyContainer GetUnityDependencyResolver ( )
136
- {
137
- var container = new UnityContainer ( ) ;
138
-
139
- container . RegisterType < ILogger , ConsoleLogger > ( ) ;
140
- container . RegisterType < ExamplePublisher > ( ) ;
141
-
142
- return new UnityDependencyResolver ( container ) ;
143
- }
144
-
145
-
146
131
internal static IDependencyContainer GetNinjectDependencyResolver ( )
147
132
{
148
133
var kernel = new StandardKernel ( ) ;
0 commit comments