示例#1
0
        public BootStrap(ServiceLocator serviceLocator)
        {
            var webClient = new DelegateWebClient();

            var sessionHelper = new SessionHelper(webClient);

            var serviceSetup = new ServiceSetup()
            {
                BaseUrl = "http://localhost:3022",
            };

            serviceLocator.Navigator = (Application.Current as App).RootFrame;

            #if NO_SERVICE
            serviceLocator.AccountService = new FakeAccountService();
            #else
            serviceLocator.AccountService = new AccountService(webClient, serviceSetup, sessionHelper);
            #endif

            serviceLocator.AccountViewModel = new AccountViewModel(serviceLocator.AccountService, serviceLocator.Navigator);

            #if NO_SERVICE
            serviceLocator.GameService = new FakeGameService();
            #else
            serviceLocator.GameService = new GameService(webClient, serviceSetup);
            #endif

            serviceLocator.MenuGameViewModel = new MenuGameViewModel(serviceLocator.GameService, serviceLocator.Navigator);

            serviceLocator.GameViewModel = new GameViewModel(serviceLocator.GameService);
        }
示例#2
0
        private void SetupPreRequest(DelegateWebClient webClient)
        {
            if (webClient.PrepareRequestHook == null)
            {
                webClient.PrepareRequestHook = reg => { };
            }

            var decoratedPreRequestHook = webClient.PrepareRequestHook.DecorateWithWp7Headers();
            decoratedPreRequestHook = decoratedPreRequestHook.DecorateWithWp7SessionHeaders(() => this.AuthToken);

            webClient.PrepareRequestHook = decoratedPreRequestHook;
        }
示例#3
0
        public SessionHelper(DelegateWebClient webClient)
        {
            SetupPreRequest(webClient);

            if (webClient.RequestSuccessHook == null)
            {
                webClient.RequestSuccessHook = resp => { };
            }

            webClient.RequestSuccessHook = webClient.RequestSuccessHook.DecorateWithWp7SessionCatcher(authToken =>
                {
                    this.AuthToken = authToken;
                });
        }
示例#4
0
 public AccountService(DelegateWebClient webClient, ServiceSetup serviceSetup, SessionHelper sessionHelper)
 {
     this.webClient = webClient;
     this.serviceSetup = serviceSetup;
     this.sessionHelper = sessionHelper;
 }