File tree 1 file changed +25
-1
lines changed
Samples/FullDuplex/MyServer
1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ namespace MyServer
7
7
8
8
public class MyOwnUnitOfWork : IManageUnitsOfWork
9
9
{
10
+ public IMySession MySession { get ; set ; }
11
+
10
12
public void Begin ( )
11
13
{
12
14
LogMessage ( "Begin" ) ;
@@ -15,7 +17,10 @@ public void Begin()
15
17
public void End ( Exception ex )
16
18
{
17
19
if ( ex == null )
20
+ {
18
21
LogMessage ( "Commit" ) ;
22
+ MySession . SaveChanges ( ) ;
23
+ }
19
24
else
20
25
LogMessage ( "Rollback, reason: " + ex ) ;
21
26
}
@@ -26,11 +31,30 @@ void LogMessage(string message)
26
31
}
27
32
}
28
33
34
+ public interface IMySession
35
+ {
36
+ void SaveChanges ( ) ;
37
+ }
38
+
39
+ public class ExampleSession : IMySession
40
+ {
41
+ public void SaveChanges ( )
42
+ {
43
+ Console . WriteLine ( string . Format ( "ExampleSession({0}) - {1}" , GetHashCode ( ) , "Saving changes" ) ) ;
44
+ }
45
+ }
46
+
29
47
public class UoWIntitializer : IWantCustomInitialization
30
48
{
31
49
public void Init ( )
32
50
{
33
- Configure . Instance . Configurer . ConfigureComponent < MyOwnUnitOfWork > ( DependencyLifecycle . InstancePerUnitOfWork ) ;
51
+ Configure . Instance . Configurer .
52
+ ConfigureComponent < MyOwnUnitOfWork > ( DependencyLifecycle . InstancePerUnitOfWork ) ;
53
+
54
+ //this shows the new lambda feature introduced in NServiceBus 3.2.3
55
+ Configure . Instance . Configurer .
56
+ ConfigureComponent < IMySession > ( ( ) => new ExampleSession ( ) , DependencyLifecycle . InstancePerUnitOfWork ) ;
57
+
34
58
}
35
59
}
36
60
}
You can’t perform that action at this time.
0 commit comments