示例#1
0
        protected override async Task OnInitializeAsync(IActivatedEventArgs args)
        {
            await base.OnInitializeAsync(args);

            _container.RegisterInstance <ISessionStateService>(SessionStateService);
            _container.RegisterInstance <INavigationService>(NavigationService);

            _container.RegisterType <ICredentialService, CredentialService>(new ContainerControlledLifetimeManager());
            _container.RegisterType <NetworkManager>(new ContainerControlledLifetimeManager());
            _container.RegisterType <TileManager>(new ContainerControlledLifetimeManager());
            _container.RegisterInstance(_appSettingsService);
            _container.RegisterInstance(_telemetryClient);
            _container.RegisterType <ImageManager>(new ContainerControlledLifetimeManager());

            var uri  = new Uri("ms-appx:///Assets/ApiAuth.json");
            var file = await StorageFile.GetFileFromApplicationUriAsync(uri);

            var strData = await FileIO.ReadTextAsync(file);

            var data = JObject.Parse(strData);

            var appId  = data["AppId"].ToString();
            var appKey = data["AppKey"].ToString();

            _apiClient = new ApiClient(appId, appKey);
            _container.RegisterInstance(_apiClient);

            var localStorageManager = new LocalStorageManager(_telemetryClient);

            localStorageManager.Init();
            _container.RegisterInstance(localStorageManager);

            var savedStreamManager = new SavedStreamManager(localStorageManager);

            _container.RegisterInstance(savedStreamManager);

            _tagsManager = _container.Resolve <TagsManager>();
            _container.RegisterInstance(_tagsManager);
            _tagsManager.ProcessQueue();

            Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = _appSettingsService.DisplayCulture;

            var unityServiceLocator = new UnityServiceLocator(_container);

            ServiceLocator.SetLocatorProvider(() => unityServiceLocator);

            ViewModelLocationProvider.SetDefaultViewModelFactory(ViewModelFactory);
            ViewModelLocationProvider.SetDefaultViewTypeToViewModelTypeResolver(ViewModelTypeResolver);
        }
示例#2
0
		protected override async Task OnInitializeAsync(IActivatedEventArgs args)
		{
			await base.OnInitializeAsync(args);

			_container.RegisterInstance<ISessionStateService>(SessionStateService);
			_container.RegisterInstance<INavigationService>(NavigationService);

			_container.RegisterType<ICredentialService, CredentialService>(new ContainerControlledLifetimeManager());
			_container.RegisterType<NetworkManager>(new ContainerControlledLifetimeManager());
			_container.RegisterType<TileManager>(new ContainerControlledLifetimeManager());
			_container.RegisterInstance(_appSettingsService);
			_container.RegisterInstance(_telemetryClient);
			_container.RegisterType<ImageManager>(new ContainerControlledLifetimeManager());

			var uri = new Uri("ms-appx:///Assets/ApiAuth.json");
			var file = await StorageFile.GetFileFromApplicationUriAsync(uri);
			var strData = await FileIO.ReadTextAsync(file);
			var data = JObject.Parse(strData);

			var appId = data["AppId"].ToString();
			var appKey = data["AppKey"].ToString();
			_apiClient = new ApiClient(appId, appKey);
			_container.RegisterInstance(_apiClient);

			var localStorageManager = new LocalStorageManager(_telemetryClient);
			localStorageManager.Init();
			_container.RegisterInstance(localStorageManager);

			var savedStreamManager = new SavedStreamManager(localStorageManager);
			_container.RegisterInstance(savedStreamManager);

			_tagsManager = _container.Resolve<TagsManager>();
			_container.RegisterInstance(_tagsManager);
			_tagsManager.ProcessQueue();

			Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = _appSettingsService.DisplayCulture;

			var unityServiceLocator = new UnityServiceLocator(_container);
			ServiceLocator.SetLocatorProvider(() => unityServiceLocator);

			ViewModelLocationProvider.SetDefaultViewModelFactory(ViewModelFactory);
			ViewModelLocationProvider.SetDefaultViewTypeToViewModelTypeResolver(ViewModelTypeResolver);
		}