Esempio n. 1
0
        public void InitalizeViewModel()
        {
            // In your application you will want to inject IAdaptiveClient into your ViewModels much the same way as is
            // done in the Demo class in this project.
            // Because this is a demo, we want to create conditions where Adaptive client can demonstrate its fall back capabilities.
            // We register the components of this application as well as some mocks to accomplish that goal.

            // First pass - connect to SQL box on LAN:

            using (var scope = new ContainerBuilder().Build().BeginLifetimeScope(builder => AutofacHelper.RegisterComponents(builder)))
            {
                Demo       demo   = scope.Resolve <Demo>();
                API_Result result = demo.Simulate_API_Calls();
                result.Title = "First pass - connect to SQL box on local area network:";
                ServiceCallResults.Add(result);
            }


            // Second pass - simulate no LAN connectivity, fall back to WebAPI server:

            using (var scope = new ContainerBuilder().Build().BeginLifetimeScope(builder => AutofacHelper.RegisterMocks(builder)))
            {
                Demo       demo   = scope.Resolve <Demo>();
                API_Result result = demo.Simulate_API_Calls();
                result.Title = "Second pass - simulate no LAN connectivity, fall back to WebAPI server:";
                ServiceCallResults.Add(result);
            }
        }
 public Demo(IAdaptiveClient <IUsersService> adaptiveClient)
 {
     this.adaptiveClient = adaptiveClient;
     this.apiResult      = new API_Result();
 }