File tree 3 files changed +16
-15
lines changed
src/SampleApps/SampleApp.WindowsServiceHosted
3 files changed +16
-15
lines changed Original file line number Diff line number Diff line change @@ -17,22 +17,21 @@ private static void Main(string[] args)
17
17
18
18
Args = args ;
19
19
20
- InitializeContainer ( ) ;
20
+ DIContainer . Current . RegisterAll ( ) . Verify ( ) ;
21
21
22
- if ( new BasicServiceHandler < WebApplicationStartup > ( ) . Start ( args ) )
23
- return ;
22
+ using var handler = new BasicServiceHandler < WebApplicationStartup > ( ) ;
24
23
25
- using ( var scope = DIContainer . Current . BeginLifetimeScope ( ) )
26
- scope . Resolver . Resolve < WebApplicationStartup > ( ) . Run ( ) ;
27
-
28
- Console . ReadLine ( ) ;
24
+ if ( ! handler . Start ( args ) )
25
+ RunAsAConsoleApplication ( ) ;
29
26
}
30
27
31
- private static void InitializeContainer ( )
28
+ private static void RunAsAConsoleApplication ( )
32
29
{
33
- IocRegistrations . Register ( ) ;
30
+ using var scope = DIContainer . Current . BeginLifetimeScope ( ) ;
34
31
35
- DIContainer . Current . Verify ( ) ;
32
+ scope . Resolver . Resolve < WebApplicationStartup > ( ) . Run ( ) ;
33
+
34
+ Console . ReadLine ( ) ;
36
35
}
37
36
}
38
37
}
Original file line number Diff line number Diff line change 1
1
<Project Sdk =" Microsoft.NET.Sdk" >
2
2
<PropertyGroup >
3
3
<TargetFrameworks >net462</TargetFrameworks >
4
+ <LangVersion >8.0</LangVersion >
4
5
<Authors >Alexander Krylkov</Authors >
5
6
<Product >Simplify</Product >
6
7
<Description >Simplify.Web as windows service sample app</Description >
Original file line number Diff line number Diff line change 3
3
4
4
namespace SampleApp . WindowsServiceHosted . Setup
5
5
{
6
- public class IocRegistrations
6
+ public static class IocRegistrations
7
7
{
8
- public static void Register ( )
8
+ public static IDIContainerProvider RegisterAll ( this IDIContainerProvider container )
9
9
{
10
- DIContainer . Current . Register < WebApplicationStartup > ( ) ;
11
-
12
10
// Manual Simplify.Web bootstrapper registration
13
- DIContainer . Current . RegisterSimplifyWeb ( ) ;
11
+ container . RegisterSimplifyWeb ( )
12
+ . Register < WebApplicationStartup > ( ) ;
13
+
14
+ return container ;
14
15
}
15
16
}
16
17
}
You can’t perform that action at this time.
0 commit comments