private static void CreateClient() { try { _logger.Info("Creating API Client"); var device = new Device { DeviceId = SharedUtils.GetDeviceId(), DeviceName = SharedUtils.GetDeviceName() }; var server = ApplicationSettings.Get <ServerInfo>(Constants.Settings.DefaultServerConnection); if (server == null) { _logger.Info("No server details found"); return; } var serverAddress = server.LastConnectionMode.HasValue && server.LastConnectionMode.Value == ConnectionMode.Manual ? server.ManualAddress : server.RemoteAddress; var client = new ApiClient(MediaBrowserLogger, serverAddress, "Windows Phone 8", device, ApplicationManifest.Current.App.Version, new CryptographyProvider()); client.SetAuthenticationInfo(server.AccessToken, server.UserId); _logger.Info("Client created"); _apiClient = client; } catch (Exception ex) { _logger.FatalException("Error creating ApiClient", ex); } }
private static void CreateClient() { try { _logger.Info("Creating Client"); var device = new Device { DeviceId = SharedUtils.GetDeviceId(), DeviceName = SharedUtils.GetDeviceName() }; var server = ApplicationSettings.Get <ServerInfo>(Constants.Settings.DefaultServerConnection); var auth = ApplicationSettings.Get <AuthenticationResult>(Constants.Settings.AuthUserSetting); if (server == null || auth == null || auth.User == null) { if (server == null) { _logger.Info("No server information!"); } if (auth == null) { _logger.Info("No authentication info"); } if (auth != null && auth.User == null) { _logger.Info("No User info available"); } return; } var serverAddress = server.LastConnectionMode.HasValue && server.LastConnectionMode.Value == ConnectionMode.Manual ? server.ManualAddress : server.RemoteAddress; _logger.Info("LastConnectionMode used: {0}", server.LastConnectionMode.HasValue && server.LastConnectionMode.Value == ConnectionMode.Manual ? ConnectionMode.Manual : ConnectionMode.Remote); var client = new ApiClient(_mbLogger, serverAddress, "Windows Phone 8", device, ApplicationManifest.Current.App.Version, new CryptographyProvider()); client.SetAuthenticationInfo(auth.AccessToken, auth.User.Id); _apiClient = client; } catch (Exception ex) { _logger.FatalException("Error creating ApiClient", ex); } }
static ViewModelLocator() { ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); var device = new Device { DeviceName = SharedUtils.GetDeviceName(), DeviceId = SharedUtils.GetDeviceId() }; var logger = new MBLogger(); var network = new NetworkConnection(); SimpleIoc.Default.RegisterIf <ILogger>(() => logger); SimpleIoc.Default.RegisterIf <IDevice>(() => device); SimpleIoc.Default.RegisterIf <INetworkConnection>(() => network); if (ViewModelBase.IsInDesignModeStatic) { SimpleIoc.Default.RegisterIf <INavigationService, NavigationService>(); SimpleIoc.Default.RegisterIf <FolderViewModel>(); SimpleIoc.Default.RegisterIf <MovieViewModel>(); SimpleIoc.Default.RegisterIf <IApplicationSettingsService, ApplicationSettingsDesignService>(); SimpleIoc.Default.RegisterIf <IStorageService, StorageDesignService>(); SimpleIoc.Default.RegisterIf <ILocalAssetManager, NullAssetManager>(); } else { SimpleIoc.Default.RegisterIf <INavigationService, NavigationService>(); SimpleIoc.Default.RegisterIf <ISettingsService, SettingsService>(); SimpleIoc.Default.RegisterIf <IMessengerService, MessengerService>(); SimpleIoc.Default.RegisterIf(() => Utils.CreateConnectionManager(device, logger, network)); SimpleIoc.Default.RegisterIf <IApplicationSettingsService, ApplicationSettingsService>(); SimpleIoc.Default.RegisterIf <IStorageService, StorageService>(); SimpleIoc.Default.RegisterIf <IServerInfoService, ServerInfoService>(); SimpleIoc.Default.RegisterIf <AuthenticationService>(true); SimpleIoc.Default.RegisterIf <LockScreenService>(true); SimpleIoc.Default.RegisterIf <TileService>(true); SimpleIoc.Default.RegisterIf <TrialHelper>(true); SimpleIoc.Default.RegisterIf <IMessagePromptService, MessagePromptService>(); SimpleIoc.Default.RegisterIf <ITransferService, TransferService>(); AddSyncInterfaces(); SimpleIoc.Default.RegisterIf <IPlaybackManager>(() => new PlaybackManager(AssetManager, device, logger, network)); } SimpleIoc.Default.RegisterIf <IMessageBoxService, MessageBoxService>(); SimpleIoc.Default.Register <MainViewModel>(); SimpleIoc.Default.Register <VideoPlayerViewModel>(); SimpleIoc.Default.Register <SplashscreenViewModel>(); SimpleIoc.Default.Register <ChooseProfileViewModel>(); SimpleIoc.Default.Register <TvViewModel>(); SimpleIoc.Default.Register <TrailerViewModel>(); SimpleIoc.Default.Register <SettingsViewModel>(); SimpleIoc.Default.Register <MusicViewModel>(); SimpleIoc.Default.Register <SearchViewModel>(); SimpleIoc.Default.Register <NowPlayingViewModel>(true); SimpleIoc.Default.Register <NotificationsViewModel>(); SimpleIoc.Default.Register <RemoteViewModel>(); SimpleIoc.Default.Register <MovieCollectionViewModel>(); SimpleIoc.Default.Register <TvCollectionViewModel>(); SimpleIoc.Default.Register <MusicCollectionViewModel>(); SimpleIoc.Default.Register <ActorViewModel>(); SimpleIoc.Default.Register <GenericItemViewModel>(); SimpleIoc.Default.Register <LiveTvChannelsViewModel>(); SimpleIoc.Default.Register <GuideViewModel>(); SimpleIoc.Default.Register <ScheduleViewModel>(); SimpleIoc.Default.Register <LiveTvViewModel>(); SimpleIoc.Default.Register <ScheduledSeriesViewModel>(); SimpleIoc.Default.Register <ScheduledRecordingViewModel>(); SimpleIoc.Default.Register <AllProgrammesViewModel>(); SimpleIoc.Default.Register <ProgrammeViewModel>(); SimpleIoc.Default.Register <RecordedTvViewModel>(); SimpleIoc.Default.Register <ChannelViewModel>(); SimpleIoc.Default.Register <ChannelsViewModel>(); SimpleIoc.Default.Register <ServerPlaylistsViewModel>(); SimpleIoc.Default.Register <AddToPlaylistViewModel>(); SimpleIoc.Default.Register <PhotoUploadViewModel>(); SimpleIoc.Default.Register <MbConnectViewModel>(); SimpleIoc.Default.Register <SyncViewModel>(); SimpleIoc.Default.Register <CurrentDownloadsViewModel>(); SimpleIoc.Default.Register <SyncJobDetailViewModel>(); SimpleIoc.Default.Register <UnlockFeaturesViewModel>(); SimpleIoc.Default.Register <ConnectSignUpViewModel>(); }