コード例 #1
0
ファイル: GatewayService.cs プロジェクト: rafal06/Quarrel
 /// <summary>
 /// Initializes a new instance of the <see cref="GatewayService"/> class.
 /// </summary>
 /// <param name="analyticsService">The app's analytics service.</param>
 /// <param name="cacheService">The app's cache service.</param>
 /// <param name="channelsService">The app's current user service.</param>
 /// <param name="currentUserService">The app's channels service.</param>
 /// <param name="guildsService">The app's guilds service.</param>
 /// <param name="serviceProvider">The app's service provider.</param>
 public GatewayService(
     IAnalyticsService analyticsService,
     ICacheService cacheService,
     IChannelsService channelsService,
     ICurrentUserService currentUserService,
     IGuildsService guildsService,
     IServiceProvider serviceProvider)
 {
     _analyticsService   = analyticsService;
     _cacheService       = cacheService;
     _channelsService    = channelsService;
     _currentUserService = currentUserService;
     _guildsService      = guildsService;
     _serviceProvider    = serviceProvider;
 }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CurrentUsersService"/> class.
        /// </summary>
        /// <param name="cacheService">The app's cache service.</param>
        /// <param name="guildsService">The app's guild service.</param>
        /// <param name="presenceService">The app's presence service.</param>
        /// <param name="dispatcherHelper">The app's dispatcher helper.</param>
        public CurrentUsersService(ICacheService cacheService, IGuildsService guildsService, IPresenceService presenceService, IDispatcherHelper dispatcherHelper)
        {
            _cacheService     = cacheService;
            _guildsService    = guildsService;
            _presenceService  = presenceService;
            _dispatcherHelper = dispatcherHelper;

            Messenger.Default.Register <GatewayReadyMessage>(this, m =>
            {
                _dispatcherHelper.CheckBeginInvokeOnUi(() =>
                {
                    CurrentUser.Model    = m.EventData.User;
                    CurrentUser.Presence = new DiscordAPI.Models.Presence()
                    {
                        User    = null,
                        Game    = null,
                        GuildId = null,
                        Roles   = null,
                        Status  = m.EventData.Settings.Status,
                    };

                    CurrentUserSettings = m.EventData.Settings;
                    _presenceService.UpdateUserPrecense(CurrentUser.Model.Id, CurrentUser.Presence);
                });
            });
            Messenger.Default.Register <GatewayUserSettingsUpdatedMessage>(this, m =>
            {
                _dispatcherHelper.CheckBeginInvokeOnUi(() =>
                {
                    CurrentUserSettings = m.Settings;

                    if (!string.IsNullOrEmpty(m.Settings.Status))
                    {
                        var newPresence = new DiscordAPI.Models.Presence()
                        {
                            User    = CurrentUser.Presence.User,
                            Game    = CurrentUser.Presence.Game,
                            GuildId = CurrentUser.Presence.GuildId,
                            Roles   = CurrentUser.Presence.Roles,
                            Status  = m.Settings.Status,
                        };
                        CurrentUser.Presence = newPresence;
                        _presenceService.UpdateUserPrecense(CurrentUser.Model.Id, CurrentUser.Presence);
                    }
                });
            });
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainViewModel"/> class.
        /// </summary>
        /// <param name="analyticsService">The app's analytics service.</param>
        /// <param name="cacheService">The app's cache service.</param>
        /// <param name="settingsService">The app's settings service.</param>
        /// <param name="channelsService">The app's channel service.</param>
        /// <param name="discordService">The app's discord service.</param>
        /// <param name="currentUserService">The app's current user service.</param>
        /// <param name="gatewayService">The app's gateway service.</param>
        /// <param name="presenceService">The app's presence service.</param>
        /// <param name="guildsService">The app's guilds service.</param>
        /// <param name="subFrameNavigationService">The app's subframe navigation service.</param>
        /// <param name="friendsService">The app's friends service.</param>
        /// <param name="dispatcherHelper">The app's dispatcher helper.</param>
        /// <param name="voiceService">The app's voice service.</param>
        /// <param name="clipboardService">The app's clipboard service.</param>
        /// <remarks>Takes all service parameters from ViewModel Locator.</remarks>
        public MainViewModel(
            IAnalyticsService analyticsService,
            ICacheService cacheService,
            ISettingsService settingsService,
            IChannelsService channelsService,
            IDiscordService discordService,
            ICurrentUserService currentUserService,
            IGatewayService gatewayService,
            IPresenceService presenceService,
            IGuildsService guildsService,
            ISubFrameNavigationService subFrameNavigationService,
            IFriendsService friendsService,
            IDispatcherHelper dispatcherHelper,
            IVoiceService voiceService,
            IClipboardService clipboardService)
        {
            _analyticsService   = analyticsService;
            _cacheService       = cacheService;
            _settingsService    = settingsService;
            _discordService     = discordService;
            _currentUserService = currentUserService;
            _channelsService    = channelsService;
            _friendsService     = friendsService;
            _presenceService    = presenceService;

            _gatewayService            = gatewayService;
            _guildsService             = guildsService;
            _subFrameNavigationService = subFrameNavigationService;
            _dispatcherHelper          = dispatcherHelper;
            _voiceService     = voiceService;
            _clipboardService = clipboardService;

            RegisterGenericMessages();
            RegisterChannelsMessages();
            RegisterGuildsMessages();
            RegisterMembersMessages();
            RegisterMessagesMessages();
        }