コード例 #1
0
 public SavedItemPageViewModel([NotNull] SavedStreamManager savedStreamManager)
 {
     if (savedStreamManager == null)
     {
         throw new ArgumentNullException("savedStreamManager");
     }
     _savedStreamManager = savedStreamManager;
 }
コード例 #2
0
        public SavedPageViewModel([NotNull] SavedStreamManager savedStreamManager, INavigationService navigationService)
        {
            if (savedStreamManager == null)
            {
                throw new ArgumentNullException("savedStreamManager");
            }
            if (navigationService == null)
            {
                throw new ArgumentNullException("navigationService");
            }

            _savedStreamManager = savedStreamManager;
            _navigationService  = navigationService;
        }
コード例 #3
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);
        }
コード例 #4
0
 public ListStreamPageViewModel([NotNull] ApiClient apiClient,
                                [NotNull] INavigationService navigationService,
                                [NotNull] TelemetryClient telemetryClient,
                                [NotNull] TagsManager tagsManager,
                                [NotNull] AppSettingsService settingsService,
                                [NotNull] SavedStreamManager savedStreamManager,
                                [NotNull] LocalStorageManager localStorageManager,
                                [NotNull] NetworkManager networkManager)
     : base(apiClient,
            navigationService,
            telemetryClient,
            tagsManager,
            settingsService,
            savedStreamManager,
            localStorageManager,
            networkManager)
 {
 }
コード例 #5
0
ファイル: App.xaml.cs プロジェクト: valeronm/handyNews
		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);
		}