コード例 #1
0
        public RelatedVideosSidePaneContentViewModel(
            NicoVideoProvider nicoVideoProvider,
            ChannelProvider channelProvider,
            MylistRepository mylistRepository,
            HohoemaPlaylist hohoemaPlaylist,
            PageManager pageManager,
            IScheduler scheduler
            )
        {
            NicoVideoProvider = nicoVideoProvider;
            ChannelProvider   = channelProvider;
            _mylistRepository = mylistRepository;
            HohoemaPlaylist   = hohoemaPlaylist;
            PageManager       = pageManager;
            _scheduler        = scheduler;

            HasVideoDescription = _VideoViewerHelpInfo != null;

            HohoemaPlaylist.ObserveProperty(x => x.CurrentItem)
            .Subscribe(async item =>
            {
                Clear();
                _IsInitialized = false;

                await Task.Delay(1000);

                if (item != null)
                {
                    await InitializeRelatedVideos(item);
                }
            })
            .AddTo(_CompositeDisposable);
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SkillHandler"/> class,
        /// using a credential provider.
        /// </summary>
        /// <param name="adapter">An instance of the <see cref="BotAdapter"/> that will handle the request.</param>
        /// <param name="bot">The <see cref="IBot"/> instance.</param>
        /// <param name="conversationIdFactory">A <see cref="SkillConversationIdFactoryBase"/> to unpack the conversation ID and map it to the calling bot.</param>
        /// <param name="credentialProvider">The credential provider.</param>
        /// <param name="authConfig">The authentication configuration.</param>
        /// <param name="channelProvider">The channel provider.</param>
        /// <param name="logger">The ILogger implementation this adapter should use.</param>
        /// <exception cref="ArgumentNullException">throw ArgumentNullException.</exception>
        /// <remarks>Use a <see cref="MiddlewareSet"/> object to add multiple middleware
        /// components in the constructor. Use the Use(<see cref="IMiddleware"/>) method to
        /// add additional middleware to the adapter after construction.
        /// </remarks>
        public SkillHandler(
            BotAdapter adapter,
            IBot bot,
            SkillConversationIdFactoryBase conversationIdFactory,
            ICredentialProvider credentialProvider,
            AuthenticationConfiguration authConfig,
            IChannelProvider channelProvider = null,
            ILogger logger = null)
            : base(credentialProvider, authConfig, channelProvider)
        {
            if (adapter == null)
            {
                throw new ArgumentNullException(nameof(adapter));
            }

            if (bot == null)
            {
                throw new ArgumentNullException(nameof(bot));
            }

            if (conversationIdFactory == null)
            {
                throw new ArgumentNullException(nameof(conversationIdFactory));
            }

            _inner = new SkillHandlerImpl(
                SkillConversationReferenceKey,
                adapter,
                bot,
                conversationIdFactory,
                () => ChannelProvider != null && ChannelProvider.IsGovernment()
                    ? GovernmentAuthenticationConstants.ToChannelFromBotOAuthScope
                    : AuthenticationConstants.ToChannelFromBotOAuthScope,
                logger ?? NullLogger.Instance);
        }
コード例 #3
0
        private async Task <SkillConversationReference> GetSkillConversationReferenceAsync(string conversationId, CancellationToken cancellationToken)
        {
            SkillConversationReference skillConversationReference;

            try
            {
                skillConversationReference = await _conversationIdFactory.GetSkillConversationReferenceAsync(conversationId, cancellationToken).ConfigureAwait(false);
            }
            catch (NotImplementedException)
            {
                _logger.LogWarning("Got NotImplementedException when trying to call GetSkillConversationReferenceAsync() on the ConversationIdFactory, attempting to use deprecated GetConversationReferenceAsync() method instead.");

                // Attempt to get SkillConversationReference using deprecated method.
                // this catch should be removed once we remove the deprecated method.
                // We need to use the deprecated method for backward compatibility.
#pragma warning disable 618
                var conversationReference = await _conversationIdFactory.GetConversationReferenceAsync(conversationId, cancellationToken).ConfigureAwait(false);

#pragma warning restore 618
                skillConversationReference = new SkillConversationReference
                {
                    ConversationReference = conversationReference,
                    OAuthScope            = ChannelProvider != null && ChannelProvider.IsGovernment() ? GovernmentAuthenticationConstants.ToChannelFromBotOAuthScope : AuthenticationConstants.ToChannelFromBotOAuthScope
                };
            }

            if (skillConversationReference == null)
            {
                _logger.LogError($"Unable to get skill conversation reference for conversationId {conversationId}.");
                throw new KeyNotFoundException();
            }

            return(skillConversationReference);
        }
コード例 #4
0
        public RelatedVideosSidePaneContentViewModel(
            string rawVideoId,
            NicoVideoStreamingSessionProvider nicoVideo,
            string jumpVideoId,
            NicoVideoProvider nicoVideoProvider,
            ChannelProvider channelProvider,
            MylistProvider mylistProvider,
            Services.HohoemaPlaylist hohoemaPlaylist,
            PageManager pageManager
            )
        {
            Video                = nicoVideo;
            _JumpVideoId         = jumpVideoId;
            NicoVideoProvider    = nicoVideoProvider;
            ChannelProvider      = channelProvider;
            MylistProvider       = mylistProvider;
            HohoemaPlaylist      = hohoemaPlaylist;
            PageManager          = pageManager;
            CurrentVideoId       = rawVideoId;
            _VideoViewerHelpInfo = NicoVideoStreamingSessionProvider.GetVideoRelatedInfomationWithVideoDescription(rawVideoId);

            HasVideoDescription = _VideoViewerHelpInfo != null;

            var _ = InitializeRelatedVideos();
        }
コード例 #5
0
        protected override async Task NavigatedToAsync(CancellationToken cancelToken, NavigatedToEventArgs e, Dictionary <string, object> viewModelState)
        {
            if (e.Parameter is string)
            {
                RawChannelId = e.Parameter as string;
            }

            if (RawChannelId == null)
            {
                return;
            }

            try
            {
                var channelInfo = await ChannelProvider.GetChannelInfo(RawChannelId);

                ChannelId         = channelInfo.ChannelId;
                ChannelName       = channelInfo.Name;
                ChannelScreenName = channelInfo.ScreenName;
                ChannelOpenTime   = channelInfo.ParseOpenTime();
                ChannelUpdateTime = channelInfo.ParseUpdateTime();
            }
            catch
            {
                ChannelName = RawChannelId;
            }

            FollowToggleButtonService.SetFollowTarget(this);

            PageManager.PageTitle = ChannelName;

            await base.NavigatedToAsync(cancelToken, e, viewModelState);
        }
コード例 #6
0
ファイル: ActorRouteHandler.cs プロジェクト: jgsteeler/Magnum
        public ActorRouteHandler(FiberFactory fiberFactory, ModelBinder modelBinder, ChannelProvider <TInput> channelProvider)
        {
            _modelBinder     = modelBinder;
            _channelProvider = channelProvider;

            _fiberFactory = fiberFactory;
        }
コード例 #7
0
        protected override async void Execute(object parameter)
        {
            var currentMethod = System.Reflection.MethodBase.GetCurrentMethod();

            //Microsoft.AppCenter.Analytics.Analytics.TrackEvent($"{currentMethod.DeclaringType.Name}#{currentMethod.Name}");

            if (parameter is IVideoContentProvider provider)
            {
                string ownerName = null;
                if (string.IsNullOrEmpty(ownerName))
                {
                    if (provider.ProviderType == OwnerType.User)
                    {
                        var user = _nicoVideoOwnerRepository.Get(provider.ProviderId);
                        if (user?.ScreenName is not null)
                        {
                            ownerName = user.ScreenName;
                        }
                        else
                        {
                            ownerName = await UserProvider.GetUserNameAsync(provider.ProviderId);
                        }
                    }
                    else if (provider.ProviderType == OwnerType.Channel)
                    {
                        ownerName = await ChannelProvider.GetChannelNameWithCacheAsync(provider.ProviderId);
                    }
                }

                NgSettings.AddHiddenVideoOwnerId(provider.ProviderId.ToString(), ownerName);
            }
        }
コード例 #8
0
        private async Task <ResourceResponse> ProcessActivityAsync(ClaimsIdentity claimsIdentity, string conversationId, string replyToActivityId, Activity activity, CancellationToken cancellationToken)
        {
            SkillConversationReference skillConversationReference;

            try
            {
                skillConversationReference = await _conversationIdFactory.GetSkillConversationReferenceAsync(conversationId, cancellationToken).ConfigureAwait(false);
            }
            catch (NotImplementedException)
            {
                // Attempt to get SkillConversationReference using deprecated method.
                // this catch should be removed once we remove the deprecated method.
                // We need to use the deprecated method for backward compatibility.
#pragma warning disable 618
                var conversationReference = await _conversationIdFactory.GetConversationReferenceAsync(conversationId, cancellationToken).ConfigureAwait(false);

#pragma warning restore 618
                skillConversationReference = new SkillConversationReference
                {
                    ConversationReference = conversationReference,
                    OAuthScope            = ChannelProvider != null && ChannelProvider.IsGovernment() ? GovernmentAuthenticationConstants.ToChannelFromBotOAuthScope : AuthenticationConstants.ToChannelFromBotOAuthScope
                };
            }

            if (skillConversationReference == null)
            {
                throw new KeyNotFoundException();
            }

            ResourceResponse resourceResponse = null;

            var callback = new BotCallbackHandler(async(turnContext, ct) =>
            {
                turnContext.TurnState.Add(SkillConversationReferenceKey, skillConversationReference);
                activity.ApplyConversationReference(skillConversationReference.ConversationReference);
                turnContext.Activity.Id       = replyToActivityId;
                turnContext.Activity.CallerId = $"{CallerIdConstants.BotToBotPrefix}{JwtTokenValidation.GetAppIdFromClaims(claimsIdentity.Claims)}";
                switch (activity.Type)
                {
                case ActivityTypes.EndOfConversation:
                    await _conversationIdFactory.DeleteConversationReferenceAsync(conversationId, cancellationToken).ConfigureAwait(false);
                    ApplyEoCToTurnContextActivity(turnContext, activity);
                    await _bot.OnTurnAsync(turnContext, ct).ConfigureAwait(false);
                    break;

                case ActivityTypes.Event:
                    ApplyEventToTurnContextActivity(turnContext, activity);
                    await _bot.OnTurnAsync(turnContext, ct).ConfigureAwait(false);
                    break;

                default:
                    resourceResponse = await turnContext.SendActivityAsync(activity, cancellationToken).ConfigureAwait(false);
                    break;
                }
            });

            await _adapter.ContinueConversationAsync(claimsIdentity, skillConversationReference.ConversationReference, skillConversationReference.OAuthScope, callback, cancellationToken).ConfigureAwait(false);

            return(resourceResponse ?? new ResourceResponse(Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture)));
        }
コード例 #9
0
        public KeyedChannelProvider(ChannelProvider <TChannel> channelProvider, KeyAccessor <TChannel, TKey> keyAccessor)
        {
            ChannelProvider = channelProvider;
            _keyAccessor    = keyAccessor;

            _dictionary = new Cache <TKey, Channel <TChannel> >();
        }
コード例 #10
0
        private async Task <Tuple <string, string> > ResolveSubscriptionSourceLabel(SubscriptionSource source)
        {
            switch (source.SourceType)
            {
            case SubscriptionSourceType.User:
                var info = await UserProvider.GetUser(source.Parameter);

                return(new Tuple <string, string>(info.ScreenName, null));

            case SubscriptionSourceType.Channel:
                var channelInfo = await ChannelProvider.GetChannelInfo(source.Parameter);

                return(new Tuple <string, string>(channelInfo.Name, null));

            case SubscriptionSourceType.Mylist:
                var mylistInfo = await MylistProvider.GetMylistGroupDetail(source.Parameter);

                var mylistOwner = await UserProvider.GetUser(mylistInfo.MylistGroup.UserId);

                return(new Tuple <string, string>(mylistInfo.MylistGroup.Name, mylistOwner.ScreenName));

            case SubscriptionSourceType.TagSearch:
                return(new Tuple <string, string>(source.Parameter, null));

            case SubscriptionSourceType.KeywordSearch:
                return(new Tuple <string, string>(source.Parameter, null));

            default:
                break;
            }

            return(null);
        }
コード例 #11
0
        private async Task ProcessList()
        {
            try
            {
                IMessageChannel channel = await ChannelProvider.GetDMChannelAsync(this.Context);

                List <TReminder> reminders = this._reminderDAO.GetAll(this.Context.User.Id);
                IOrderedEnumerable <TReminder> orderedList = reminders.OrderBy(x => x.ExpirationTime);

                FormattedEmbedBuilder message = new FormattedEmbedBuilder()
                                                .AppendTitle($"{XayahReaction.Hourglass} Active reminders");
                if (orderedList.Count() > 0)
                {
                    foreach (TReminder entry in orderedList)
                    {
                        message.AddField($"Expires: {entry.ExpirationTime} UTC", entry.Message, inline: false);
                    }
                }
                else
                {
                    message.AppendDescription("imagine a soulrending void", AppendOption.Italic);
                }
                await channel.SendEmbedAsync(message);

                await this.Context.Message.AddReactionIfNotDMAsync(this.Context, XayahReaction.Envelope);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
コード例 #12
0
        public ChannelVideoPageViewModel(
            ILoggerFactory loggerFactory,
            ApplicationLayoutManager applicationLayoutManager,
            NiconicoSession niconicoSession,
            ChannelProvider channelProvider,
            ChannelFollowProvider channelFollowProvider,
            PageManager pageManager,
            VideoPlayWithQueueCommand videoPlayWithQueueCommand,
            PlaylistPlayAllCommand playlistPlayAllCommand,
            OpenLinkCommand openLinkCommand,
            SelectionModeToggleCommand selectionModeToggleCommand
            )
            : base(loggerFactory.CreateLogger <ChannelVideoPageViewModel>())
        {
            ApplicationLayoutManager = applicationLayoutManager;
            NiconicoSession          = niconicoSession;
            ChannelProvider          = channelProvider;
            _channelFollowProvider   = channelFollowProvider;
            PageManager = pageManager;
            VideoPlayWithQueueCommand  = videoPlayWithQueueCommand;
            PlaylistPlayAllCommand     = playlistPlayAllCommand;
            OpenLinkCommand            = openLinkCommand;
            SelectionModeToggleCommand = selectionModeToggleCommand;

            CurrentPlaylistToken = Observable.CombineLatest(
                this.ObserveProperty(x => x.ChannelVideoPlaylist),
                this.ObserveProperty(x => x.SelectedSortOption),
                (x, y) => new PlaylistToken(x, y)
                )
                                   .ToReadOnlyReactivePropertySlim()
                                   .AddTo(_CompositeDisposable);
        }
コード例 #13
0
        public override async Task OnNavigatedToAsync(INavigationParameters parameters)
        {
            if (parameters.TryGetValue("id", out string id))
            {
                RawChannelId = id;

                try
                {
                    var channelInfo = await ChannelProvider.GetChannelInfo(RawChannelId);

                    ChannelId         = channelInfo.ChannelId;
                    ChannelName       = channelInfo.Name;
                    ChannelScreenName = channelInfo.ScreenName;
                    ChannelOpenTime   = channelInfo.ParseOpenTime();
                    ChannelUpdateTime = channelInfo.ParseUpdateTime();
                }
                catch
                {
                    ChannelName = RawChannelId;
                }

                FollowToggleButtonService.SetFollowTarget(this);
            }

            await base.OnNavigatedToAsync(parameters);
        }
コード例 #14
0
        public static async Task <CompanyProvider> Create(ChannelProvider provider)
        {
            var companyNavigationSource = new CompanyProvider(provider);
            await companyNavigationSource.Initialize();

            return(companyNavigationSource);
        }
コード例 #15
0
        public ThreadPoolChannel(ChannelProvider <T> instanceProvider, int channelLimit)
        {
            Guard.GreaterThan(0, channelLimit, "channelLimit");

            _channelLimit    = channelLimit;
            _channelCount    = 0;
            InstanceProvider = instanceProvider;
        }
コード例 #16
0
        /// <summary>
        /// Creates a streaming specific connector client.
        /// </summary>
        private IConnectorClient CreateStreamingConnectorClient(Activity activity, StreamingRequestHandler requestHandler)
        {
            var emptyCredentials = (ChannelProvider != null && ChannelProvider.IsGovernment()) ?
                                   MicrosoftGovernmentAppCredentials.Empty :
                                   MicrosoftAppCredentials.Empty;
            var streamingClient = new StreamingHttpClient(requestHandler, Logger);
            var connectorClient = new ConnectorClient(new Uri(activity.ServiceUrl), emptyCredentials, customHttpClient: streamingClient);

            return(connectorClient);
        }
コード例 #17
0
 public AddToHiddenUserCommand(
     NGSettings ngSettings,
     ChannelProvider channelProvider,
     UserProvider userProvider
     )
 {
     NgSettings      = ngSettings;
     ChannelProvider = channelProvider;
     UserProvider    = userProvider;
 }
コード例 #18
0
        ChannelProvider <T> WithVertex <T>(Func <ChannelProvider <T> > scopedAction)
        {
            _stack.Push(_current);

            ChannelProvider <T> result = scopedAction();

            _stack.Pop();

            return(result);
        }
コード例 #19
0
        public CacheChannelProvider(FiberProvider <TKey> fiberProvider, ChannelProvider <TChannel> channelProvider,
                                    KeyAccessor <TChannel, TKey> keyAccessor)
        {
            Guard.AgainstNull(fiberProvider);
            Guard.AgainstNull(channelProvider);
            Guard.AgainstNull(keyAccessor);

            _fiberProvider   = fiberProvider;
            _channelProvider = channelProvider;
            _keyAccessor     = keyAccessor;
        }
コード例 #20
0
        public void AddRoute <TActor, TInput>(ChannelProvider <TInput> provider, PropertyInfo property)
        {
            var routeHandler = new ActorRouteHandler <TInput>(() => new ThreadPoolFiber(), _modelBinder, provider);

            RouteValueDictionary routeValueDictionary = ActorRouteGenerator.GetRouteValuesForActor <TActor>(property);

            string url = BasePath.TrimEnd('/') + "/{Actor}/{Channel}";

            var route = new Route(url, new RouteValueDictionary(), routeValueDictionary, routeHandler);

            _routeCollection.Add(route);
        }
コード例 #21
0
 public HiddenVideoOwnerAddCommand(
     VideoFilteringSettings ngSettings,
     ChannelProvider channelProvider,
     UserProvider userProvider,
     NicoVideoOwnerCacheRepository nicoVideoOwnerRepository
     )
 {
     NgSettings                = ngSettings;
     ChannelProvider           = channelProvider;
     UserProvider              = userProvider;
     _nicoVideoOwnerRepository = nicoVideoOwnerRepository;
 }
コード例 #22
0
        /// <summary>
        /// Creates a streaming specific connector client.
        /// </summary>
        private IConnectorClient CreateStreamingConnectorClient(Activity activity, StreamingRequestHandler requestHandler)
        {
            var emptyCredentials = (ChannelProvider != null && ChannelProvider.IsGovernment()) ?
                                   MicrosoftGovernmentAppCredentials.Empty :
                                   MicrosoftAppCredentials.Empty;

#pragma warning disable CA2000 // Dispose objects before losing scope (We need to make ConnectorClient disposable to fix this, ignoring it for now)
            var streamingClient = new StreamingHttpClient(requestHandler, Logger);
#pragma warning restore CA2000 // Dispose objects before losing scope
            var connectorClient = new ConnectorClient(new Uri(activity.ServiceUrl), emptyCredentials, customHttpClient: streamingClient);
            return(connectorClient);
        }
コード例 #23
0
        public ChannelProvider <TChannel> GetChannelProvider(ChannelConfiguratorConnection <TChannel> connection)
        {
            if (_providerFactory == null)
            {
                throw new ChannelConfigurationException(typeof(TChannel), "No instance provider was specified in the configuration");
            }

            ChannelProvider <TChannel> provider = _providerFactory(connection);

            var keyedProvider = new KeyedChannelProvider <TChannel, TKey>(provider, _keyAccessor);

            return(keyedProvider);
        }
コード例 #24
0
 public RelatedVideoContentsAggregator(
     NicoVideoProvider nicoVideoProvider,
     ChannelProvider channelProvider,
     MylistRepository mylistRepository,
     HohoemaPlaylist hohoemaPlaylist,
     PageManager pageManager
     )
 {
     NicoVideoProvider = nicoVideoProvider;
     ChannelProvider   = channelProvider;
     _mylistRepository = mylistRepository;
     HohoemaPlaylist   = hohoemaPlaylist;
     PageManager       = pageManager;
 }
コード例 #25
0
 public RelatedVideoContentsAggregator(
     NiconicoSession niconicoSession,
     NicoVideoProvider nicoVideoProvider,
     ChannelProvider channelProvider,
     MylistResolver mylistRepository,
     PageManager pageManager
     )
 {
     _niconicoSession   = niconicoSession;
     _nicoVideoProvider = nicoVideoProvider;
     _channelProvider   = channelProvider;
     _mylistRepository  = mylistRepository;
     _pageManager       = pageManager;
 }
コード例 #26
0
 public AddSubscriptionCommand(
     SubscriptionManager subscriptionManager,
     UserProvider userProvider,
     ChannelProvider channelProvider,
     NotificationService notificationService,
     SeriesProvider seriesRepository
     )
 {
     _subscriptionManager = subscriptionManager;
     _userProvider        = userProvider;
     _channelProvider     = channelProvider;
     _notificationService = notificationService;
     _seriesRepository    = seriesRepository;
 }
コード例 #27
0
        public void SetUp()
        {
            routingTopology  = new ConventionalRoutingTopology(true);
            receivedMessages = new BlockingCollection <IncomingMessage>();

            var settings = new SettingsHolder();

            settings.Set("NServiceBus.Routing.EndpointName", "endpoint");

            var connectionString = Environment.GetEnvironmentVariable("RabbitMQTransport.ConnectionString");

            ConnectionConfiguration config;

            if (connectionString != null)
            {
                var parser = new ConnectionStringParser(settings);
                config = parser.Parse(connectionString);
            }
            else
            {
                config      = new ConnectionConfiguration(settings);
                config.Host = "localhost";
            }

            connectionFactory = new ConnectionFactory(config);
            channelProvider   = new ChannelProvider(connectionFactory, routingTopology, true);

            messageDispatcher = new MessageDispatcher(channelProvider);

            var purger = new QueuePurger(connectionFactory);

            messagePump = new MessagePump(connectionFactory, new MessageConverter(), "Unit test", channelProvider, purger, TimeSpan.FromMinutes(2), 3, 0);

            MakeSureQueueAndExchangeExists(ReceiverQueue);

            subscriptionManager = new SubscriptionManager(connectionFactory, routingTopology, ReceiverQueue);

            messagePump.Init(messageContext =>
            {
                receivedMessages.Add(new IncomingMessage(messageContext.MessageId, messageContext.Headers, messageContext.Body));
                return(TaskEx.CompletedTask);
            },
                             ErrorContext => Task.FromResult(ErrorHandleResult.Handled),
                             new CriticalError(_ => TaskEx.CompletedTask),
                             new PushSettings(ReceiverQueue, "error", true, TransportTransactionMode.ReceiveOnly)
                             ).GetAwaiter().GetResult();

            messagePump.Start(new PushRuntimeSettings(MaximumConcurrency));
        }
コード例 #28
0
        private async void HandleExpiredReminder(object state)
        {
            TReminder reminder = state as TReminder;

            await this._reminderDAO.RemoveAsync(reminder);

            StopTimer(this.BuildTimerKey(reminder.UserId, reminder.ExpirationTime));

            IMessageChannel channel = await ChannelProvider.GetDMChannelAsync(this._client, reminder.UserId);

            FormattedEmbedBuilder message = new FormattedEmbedBuilder()
                                            .AppendTitle($"{XayahReaction.Clock} Reminder expired")
                                            .AppendDescription(reminder.Message);
            await channel.SendEmbedAsync(message);
        }
コード例 #29
0
        public async Task HostAndChannelFactory()
        {
            var host = new ProtocolHost();

            host.LoadFromReference <ProtocolHostTests>();
            host.Resolver.Register(new CalculatorParameter()
            {
                First = 10
            });

            var cts        = new CancellationTokenSource();
            var serverTask = host.StartServerAsync("127.0.0.1", 91, cts.Token);

            var channelProvider = new ChannelProvider("127.0.0.1", 91);

            channelProvider.LoadFromReference <ProtocolHostTests>();
            var calculator = await channelProvider.GetChannelAsync <ICalculator>();

            var result = await calculator.AddAsync("9");

            Assert.AreEqual(19, result.Result);

            cts.Cancel();
            try
            {
                await serverTask;
            }
            catch { };

            host = new ProtocolHost();
            host.LoadFromReference <ProtocolHostTests>();
            host.Resolver.Register(new CalculatorParameter()
            {
                First = 10
            });

            serverTask = host.StartServerAsync("127.0.0.1", 91, CancellationToken.None);

            var channelProviderCollection = new ChannelProviderCollection(channelProvider);

            calculator = await channelProviderCollection.GetChannelAsync <ICalculator>();

            result = await calculator.AddAsync("9");

            Assert.AreEqual(19, result.Result);
        }
コード例 #30
0
 public ChannelVideoPageViewModel(
     ApplicationLayoutManager applicationLayoutManager,
     NiconicoSession niconicoSession,
     ChannelProvider channelProvider,
     PageManager pageManager,
     HohoemaPlaylist hohoemaPlaylist,
     ExternalAccessService externalAccessService,
     NiconicoFollowToggleButtonService followToggleButtonService
     )
 {
     ApplicationLayoutManager = applicationLayoutManager;
     NiconicoSession          = niconicoSession;
     ChannelProvider          = channelProvider;
     PageManager               = pageManager;
     HohoemaPlaylist           = hohoemaPlaylist;
     ExternalAccessService     = externalAccessService;
     FollowToggleButtonService = followToggleButtonService;
 }