Ejemplo n.º 1
0
        public ViewModelLocator()
        {
            var navigationService = new SubFrameNavigationService();

            navigationService.Configure("LoginPage", typeof(LoginPage));
            navigationService.Configure("SettingsPage", typeof(SettingsPage));
            navigationService.Configure("UserProfilePage", typeof(UserProfilePage));
            navigationService.Configure("AddChannelPage", typeof(AddChannelPage));

            SimpleIoc.Default.Register <IDispatcherHelper, DispatcherHelperEx>();
            SimpleIoc.Default.Register <ISubFrameNavigationService>(() => navigationService);

            SimpleIoc.Default.Register <ICacheService, CacheService>();
            SimpleIoc.Default.Register <ISettingsService, SettingsService>();
            SimpleIoc.Default.Register <IGatewayService, GatewayService>();
            SimpleIoc.Default.Register <IDiscordService, DiscordService>();
            SimpleIoc.Default.Register <IGuildsService, GuildsService>();
            SimpleIoc.Default.Register <IAudioInService, AudioInService>();
            SimpleIoc.Default.Register <IAudioOutService, AudioOutService>();
            SimpleIoc.Default.Register <ICurrentUsersService, CurrentUsersService>();
            SimpleIoc.Default.Register <IVoiceService, VoiceService>();

            SimpleIoc.Default.Register <MainViewModel>();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ViewModelLocator"/> class and the <see cref="MainViewModel"/>.
        /// Creates and registers all the services with <see cref="SimpleIoc.Default"/>.
        /// </summary>
        public ViewModelLocator()
        {
            if (_hasRun)
            {
                return;
            }

            _hasRun = true;

            SimpleIoc.Default.Register <IDispatcherHelper, DispatcherHelperEx>();

            var navigationService = new SubFrameNavigationService();

            navigationService.Configure("AboutPage", typeof(AboutPage));
            navigationService.Configure("AddChannelPage", typeof(AddChannelPage));
            navigationService.Configure("AddServerPage", typeof(AddServerPage));
            navigationService.Configure("AttachmentPage", typeof(AttachmentPage));
            navigationService.Configure("ChangeNicknamePage", typeof(ChangeNicknamePage));
            navigationService.Configure("CreateInvitePage", typeof(CreateInvitePage));
            navigationService.Configure("CreditPage", typeof(CreditPage));
            navigationService.Configure("DiscordStatusPage", typeof(DiscordStatusPage));
            navigationService.Configure("GuildSettingsPage", typeof(GuildSettingsPage));
            navigationService.Configure("LicensesPage", typeof(LicensesPage));
            navigationService.Configure("LoginPage", typeof(LoginPage));
            navigationService.Configure("TopicPage", typeof(TopicPage));
            navigationService.Configure("UserProfilePage", typeof(UserProfilePage));
            navigationService.Configure("UserSettingsPage", typeof(UserSettingsPage));
            navigationService.Configure("WhatsNewPage", typeof(WhatsNewPage));
            SimpleIoc.Default.Register <ISubFrameNavigationService>(() => navigationService);

            AppCenterService appCenterService = new AppCenterService();

#if !DEBUG
            appCenterService.Initialize();
#endif
            SimpleIoc.Default.Register <IAnalyticsService>(() => appCenterService);

            SimpleIoc.Default.Register <ICacheService, CacheService>();
            SimpleIoc.Default.Register <IClipboardService, ClipboardService>();
            SimpleIoc.Default.Register <IResourceService, ResourceService>();
            SimpleIoc.Default.Register <ISettingsService, SettingsService>();
            SimpleIoc.Default.Register <IServiceProvider>(() => App.ServiceProvider);
            SimpleIoc.Default.Register <IGatewayService, GatewayService>();
            SimpleIoc.Default.Register <IDiscordService, DiscordService>();
            SimpleIoc.Default.Register <IPresenceService, PresenceService>();
            SimpleIoc.Default.Register <IFriendsService, FriendsService>();
            SimpleIoc.Default.Register <IChannelsService, ChannelsService>();
            SimpleIoc.Default.Register <IGuildsService, GuildsService>();
            SimpleIoc.Default.Register <ICurrentUserService, CurrentUsersService>();
            SimpleIoc.Default.Register <IVoiceService, VoiceService>();

            SimpleIoc.Default.Register <MainViewModel>();
            SimpleIoc.Default.Register <EmojiPickerViewModel>(() =>
            {
                var tmp = Task.Run(async() => await Constants.FromFile.GetEmojiLists());
                return(new EmojiPickerViewModel(tmp.GetAwaiter().GetResult()));
            });
        }