File tree Expand file tree Collapse file tree
src/SampleApps/SampleApp.WindowsServiceHosted Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,22 +17,21 @@ private static void Main(string[] args)
1717
1818 Args = args ;
1919
20- InitializeContainer ( ) ;
20+ DIContainer . Current . RegisterAll ( ) . Verify ( ) ;
2121
22- if ( new BasicServiceHandler < WebApplicationStartup > ( ) . Start ( args ) )
23- return ;
22+ using var handler = new BasicServiceHandler < WebApplicationStartup > ( ) ;
2423
25- using ( var scope = DIContainer . Current . BeginLifetimeScope ( ) )
26- scope . Resolver . Resolve < WebApplicationStartup > ( ) . Run ( ) ;
27-
28- Console . ReadLine ( ) ;
24+ if ( ! handler . Start ( args ) )
25+ RunAsAConsoleApplication ( ) ;
2926 }
3027
31- private static void InitializeContainer ( )
28+ private static void RunAsAConsoleApplication ( )
3229 {
33- IocRegistrations . Register ( ) ;
30+ using var scope = DIContainer . Current . BeginLifetimeScope ( ) ;
3431
35- DIContainer . Current . Verify ( ) ;
32+ scope . Resolver . Resolve < WebApplicationStartup > ( ) . Run ( ) ;
33+
34+ Console . ReadLine ( ) ;
3635 }
3736 }
3837}
Original file line number Diff line number Diff line change 11<Project Sdk =" Microsoft.NET.Sdk" >
22 <PropertyGroup >
33 <TargetFrameworks >net462</TargetFrameworks >
4+ <LangVersion >8.0</LangVersion >
45 <Authors >Alexander Krylkov</Authors >
56 <Product >Simplify</Product >
67 <Description >Simplify.Web as windows service sample app</Description >
Original file line number Diff line number Diff line change 33
44namespace SampleApp . WindowsServiceHosted . Setup
55{
6- public class IocRegistrations
6+ public static class IocRegistrations
77 {
8- public static void Register ( )
8+ public static IDIContainerProvider RegisterAll ( this IDIContainerProvider container )
99 {
10- DIContainer . Current . Register < WebApplicationStartup > ( ) ;
11-
1210 // Manual Simplify.Web bootstrapper registration
13- DIContainer . Current . RegisterSimplifyWeb ( ) ;
11+ container . RegisterSimplifyWeb ( )
12+ . Register < WebApplicationStartup > ( ) ;
13+
14+ return container ;
1415 }
1516 }
1617}
You can’t perform that action at this time.
0 commit comments