public void Global_Middleware_Terminates() { _mockInteractor = Substitute.For <IInteractor <MockUseCase, IMockOutputPort> >(); _handlerResolver.ResolveInteractor <MockUseCase, IMockOutputPort>(Arg.Any <MockUseCase>()).Returns(_mockInteractor); var globalMiddleware = Substitute.For <IMiddleware>(); globalMiddleware.Execute( Arg.Any <MockUseCase>(), d => Task.FromResult(new UseCaseResult(true)), Arg.Any <CancellationToken>()) .ReturnsForAnyArgs(x => new UseCaseResult(true)) .AndDoes(x => { }); IReadOnlyList <IMiddleware> globalPipeline = new List <IMiddleware> { globalMiddleware }; _handlerResolver.ResolveGlobalMiddleware().Returns(globalPipeline); _interactorHub.Execute(new MockUseCase(), (IMockOutputPort) new MockOutputPort()); _mockInteractor.DidNotReceive().Execute( Arg.Any <MockUseCase>(), Arg.Any <MockOutputPort>(), Arg.Any <CancellationToken>()); }
public void RemoveMonitor(IInteractor monitor, string feed, bool removeAll) { // Can we find monitors for this feed in the cache? IDictionary <IInteractor, SubscriptionState> feedMonitors; if (!_monitors.TryGetValue(feed, out feedMonitors)) { return; } // Does this monitor have a subscription state? SubscriptionState subscriptionState; if (!feedMonitors.TryGetValue(monitor, out subscriptionState)) { return; } if (removeAll || --subscriptionState.Count == 0) { feedMonitors.Remove(monitor); } // If there are no topics left in the feed, remove it from the cache. if (feedMonitors.Count == 0) { _monitors.Remove(feed); } }
public void AddSubscription(IInteractor subscriber, string feed, string topic) { // Find topic subscriptions for this feed. IDictionary <string, IDictionary <IInteractor, SubscriptionState> > topicSubscriptions; if (!_subscriptions.TryGetValue(feed, out topicSubscriptions)) { _subscriptions.Add(feed, topicSubscriptions = new Dictionary <string, IDictionary <IInteractor, SubscriptionState> >()); } // Find the list of interactors that have subscribed to this topic. IDictionary <IInteractor, SubscriptionState> subscribersForTopic; if (!topicSubscriptions.TryGetValue(topic, out subscribersForTopic)) { topicSubscriptions.Add(topic, subscribersForTopic = new Dictionary <IInteractor, SubscriptionState>()); } // Find this interactor. SubscriptionState subscriptionState; if (!subscribersForTopic.TryGetValue(subscriber, out subscriptionState)) { subscribersForTopic.Add(subscriber, subscriptionState = new SubscriptionState()); } // Increment the subscription count. subscriptionState.Count = subscriptionState.Count + 1; }
internal void RequestAuthorisation(IInteractor interactor, string feed, string topic) { Log.Debug($"Requesting authorisation Interactor={interactor}, Feed={feed}, Topic={topic}"); if (!IsAuthorizationRequired(feed)) { Log.Debug("No authorisation required"); AcceptAuthorization(interactor, new AuthorizationResponse(interactor.Id, feed, topic, false, null)); } else { var authorizationRequest = new AuthorizationRequest(interactor.Id, interactor.Address, interactor.User, feed, topic); foreach (var authorizer in _repository.Find(feed, Role.Authorize)) { try { Log.Debug($"Requesting authorization from {authorizer}"); authorizer.SendMessage(authorizationRequest); } catch (Exception exception) { Log.Warn($"Failed to send {authorizer} message {authorizationRequest}", exception); } } } }
public bool ProcessCommand(IInteractor interactor, string username, string chatMessageChannel, string commandName, List <string> commandParameters) { var combinedCommand = commandName + " " + commandParameters.Aggregate((s1, s2) => s1 + " " + s2); var currentWins = _wins.GetOrAdd(chatMessageChannel, 0); if (combinedCommand.StartsWith("wins")) { if (combinedCommand.Replace(" ", "").Equals("wins++")) { currentWins++; _wins.TryAdd(chatMessageChannel, currentWins); } if (combinedCommand.Replace(" ", "").Equals("wins-reset")) { currentWins = 0; _wins.TryAdd(chatMessageChannel, currentWins); } interactor.MessageSender.sendMessage($"Currently @{chatMessageChannel} has {currentWins} booyah!", chatMessageChannel); return(true); } return(false); }
public void OnAssigned(IInteractor interactor) { if (!Journal.Instance.HasDiscoveredClue(clue.ClueTag)) { UIManager.Instance.DisplayScanPanel(); } }
public void PipeLineTest_FirstMiddleWare_Executes() { _mockInteractor = Substitute.For <IInteractor <MockUseCase, IMockOutputPort> >(); _handlerResolver.ResolveInteractor <MockUseCase, IMockOutputPort>(Arg.Any <MockUseCase>()).Returns(_mockInteractor); var middleware1 = Substitute.For <IMiddleware <MockUseCase, IMockOutputPort> >(); middleware1.Execute( Arg.Any <MockUseCase>(), Arg.Any <IMockOutputPort>(), d => Task.FromResult(new UseCaseResult(true)), Arg.Any <CancellationToken>()) .ReturnsForAnyArgs(x => new UseCaseResult(true)) .AndDoes(x => x.Arg <Func <MockUseCase, Task <UseCaseResult> > >().Invoke(x.Arg <MockUseCase>())); IReadOnlyList <IMiddleware <MockUseCase, IMockOutputPort> > pipeline = new List <IMiddleware <MockUseCase, IMockOutputPort> > { middleware1 }; _handlerResolver.ResolveMiddleware <MockUseCase, IMockOutputPort>(Arg.Any <MockUseCase>()).Returns(pipeline); _interactorHub.Execute(new MockUseCase(), (IMockOutputPort) new MockOutputPort()); middleware1.ReceivedWithAnyArgs().Execute(Arg.Any <MockUseCase>(), Arg.Any <IMockOutputPort>(), Arg.Any <Func <MockUseCase, Task <UseCaseResult> > >(), Arg.Any <CancellationToken>()); }
public void SendMulticastData(IInteractor publisher, IEnumerable <IInteractor> subscribers, MulticastData multicastData) { foreach (var subscriber in subscribers) { SendMulticastData(publisher, subscriber, multicastData); } }
internal void AddSubscription(IInteractor subscriber, string feed, string topic, AuthorizationInfo authorizationInfo) { // Find topic subscriptions for this feed. IDictionary <string, IDictionary <IInteractor, SubscriptionState> > topicCache; if (!_cache.TryGetValue(feed, out topicCache)) { _cache.Add(feed, topicCache = new Dictionary <string, IDictionary <IInteractor, SubscriptionState> >()); } // Find subscribers to this topic. IDictionary <IInteractor, SubscriptionState> subscribersForTopic; if (!topicCache.TryGetValue(topic, out subscribersForTopic)) { topicCache.Add(topic, subscribersForTopic = new Dictionary <IInteractor, SubscriptionState>()); } // Find the subscription state for this subscriber. SubscriptionState subscriptionState; if (!subscribersForTopic.TryGetValue(subscriber, out subscriptionState)) { subscribersForTopic.Add(subscriber, subscriptionState = new SubscriptionState(authorizationInfo)); } // Increment the subscription count. subscriptionState.Count = subscriptionState.Count + 1; }
public void SendUnicastData(IInteractor publisher, IInteractor subscriber, AuthorizationInfo authorization, UnicastData unicastData) { if (!publisher.HasRole(unicastData.Feed, Role.Publish)) { Log.Warn($"Rejected request from {publisher} to publish on feed {unicastData.Feed}"); return; } var clientUnicastData = authorization.IsAuthorizationRequired ? new ForwardedUnicastData(publisher.User, publisher.Address, unicastData.ClientId, unicastData.Feed, unicastData.Topic, unicastData.IsImage, unicastData.Data.Where(x => authorization.Entitlements.Contains(x.Header)).ToArray()) : new ForwardedUnicastData(publisher.User, publisher.Address, unicastData.ClientId, unicastData.Feed, unicastData.Topic, unicastData.IsImage, unicastData.Data); Log.Debug($"Sending unicast data from {publisher} to {subscriber}: {clientUnicastData}"); _repository.AddPublisher(publisher, clientUnicastData.Feed, clientUnicastData.Topic); try { subscriber.SendMessage(clientUnicastData); } catch (Exception exception) { Log.Debug($"Failed to send to subscriber {subscriber} unicast data {clientUnicastData}", exception); } }
public void Interact(IInteractor interactor) { if (!_isOpen) { if (blockingArea != null && blockingArea.IsAreaBlocked()) { StartCoroutine(CantOpenAnimation()); } else { transform.DORotateQuaternion(_baseHingeRotation * Quaternion.Euler(0, -90, 0), animationDuration); _navMeshObstacle.enabled = false; _isOpen = true; openEvent.Invoke(_isOpen); } } else { if (blockingArea != null && blockingArea.IsAreaBlocked()) { StartCoroutine(CantCloseAnimation()); } else { transform.DORotateQuaternion(_baseHingeRotation, animationDuration); _navMeshObstacle.enabled = true; _isOpen = false; openEvent.Invoke(_isOpen); } } }
public void Setup() { _useCaseInteractor = Substitute.For <IInteractor <MockUseCase, IMockOutputPort> >(); _middleware1 = Substitute.For <IMiddleware <MockUseCase, IMockOutputPort> >(); _middleware1.Execute( Arg.Any <MockUseCase>(), Arg.Any <IMockOutputPort>(), d => Task.FromResult(new UseCaseResult(true)), Arg.Any <CancellationToken>()) .ReturnsForAnyArgs(x => new UseCaseResult(true)) .AndDoes(x => x.Arg <Func <MockUseCase, Task <UseCaseResult> > >().Invoke(x.Arg <MockUseCase>())); _middleware2 = Substitute.For <IMiddleware <MockUseCase, IMockOutputPort> >(); _middleware2.Execute( Arg.Any <MockUseCase>(), Arg.Any <IMockOutputPort>(), d => Task.FromResult(new UseCaseResult(true)), Arg.Any <CancellationToken>()) .ReturnsForAnyArgs(x => new UseCaseResult(true)) .AndDoes(x => x.Arg <Func <MockUseCase, Task <UseCaseResult> > >().Invoke(x.Arg <MockUseCase>())); var container = new Container(c => { c.For <IInteractor <MockUseCase, IMockOutputPort> >().Use(_useCaseInteractor); c.For <IMiddleware <MockUseCase, IMockOutputPort> >().Use(_middleware1); c.For <IMiddleware <MockUseCase, IMockOutputPort> >().Use(_middleware2); }); _interactorHub = new Hub(new StructureMapResolver(container)); }
public void InjectAllGrabStrengthIndicator(IHandGrabber handGrab, IInteractor interactor, MaterialPropertyBlockEditor handMaterialPropertyBlockEditor) { InjectHandGrab(handGrab); InjectInteractor(interactor); InjectHandMaterialPropertyBlockEditor(handMaterialPropertyBlockEditor); }
public void RemoveRequest(IInteractor notifiable, string feed) { // Does this feed have any notifiable interactors? ISet <IInteractor> notifiables; if (!_feedToNotifiables.TryGetValue(feed, out notifiables)) { return; } // Is this interactor in the set of notifiables for this feed? if (!notifiables.Contains(notifiable)) { return; } // Remove the interactor from the set of notifiables. notifiables.Remove(notifiable); // Are there any interactors left listening to this feed? if (notifiables.Count != 0) { return; } // Remove the empty pattern from the caches. _feedToNotifiables.Remove(feed); }
public void Interacted(IInteractor interactor, string action) { if (VerifyAction(action)) { PerformAction(interactor); } }
internal void SendMulticastData(IInteractor publisher, MulticastData multicastData) { _publisherManager.SendMulticastData( publisher, _repository.GetSubscribersToFeedAndTopic(multicastData.Feed, multicastData.Topic), multicastData); }
public void UpdateCandidate() { _candidateInteractor = null; foreach (IInteractor interactor in Interactors) { interactor.UpdateCandidate(); if (interactor.HasCandidate) { if (_candidateInteractor == null) { _candidateInteractor = interactor; } else if (Compare(_candidateInteractor, interactor) > 0) { _candidateInteractor = interactor; } } } if (_candidateInteractor == null) { _candidateInteractor = Interactors[Interactors.Count - 1]; } }
public UnsubscribeFromPushNotificationsInteractorTests() { interactor = new UnsubscribeFromPushNotificationsInteractor( PushNotificationsTokenService, pushNotificationsTokenStorage, Api); }
public void SendMulticastData(IInteractor publisher, IEnumerable <KeyValuePair <IInteractor, AuthorizationInfo> > subscribers, MulticastData multicastData) { if (!(publisher == null || publisher.HasRole(multicastData.Feed, Role.Publish))) { Log.Warn($"Rejected request from {publisher} to publish to Feed {multicastData.Feed}"); return; } foreach (var subscriberAndAuthorizationInfo in subscribers) { var subscriber = subscriberAndAuthorizationInfo.Key; var authorizationInfo = subscriberAndAuthorizationInfo.Value; var subscriberMulticastData = subscriberAndAuthorizationInfo.Value.IsAuthorizationRequired ? new ForwardedMulticastData(publisher?.User ?? "internal", publisher?.Address ?? IPAddress.None, multicastData.Feed, multicastData.Topic, multicastData.IsImage, FilterDataPackets(authorizationInfo.Entitlements, multicastData.Data)) : new ForwardedMulticastData(publisher?.User ?? "internal", publisher?.Address ?? IPAddress.None, multicastData.Feed, multicastData.Topic, multicastData.IsImage, multicastData.Data); Log.Debug($"Sending multicast data from {publisher} to {subscriber}: {subscriberMulticastData}"); if (publisher != null) { _repository.AddPublisher(publisher, subscriberMulticastData.Feed, subscriberMulticastData.Topic); } try { subscriber.SendMessage(subscriberMulticastData); } catch (Exception exception) { Log.Debug($"Failed to send to subscriber {subscriber} multicast data {subscriberMulticastData}", exception); } } }
protected CalendarViewModelTest() { CalendarInteractor = Substitute.For <IInteractor <IObservable <IEnumerable <CalendarItem> > > >(); var workspace = new MockWorkspace { Id = DefaultWorkspaceId }; var timeEntry = new MockTimeEntry { Id = TimeEntryId }; TimeService.CurrentDateTime.Returns(Now); InteractorFactory .GetCalendarItemsForDate(Arg.Any <DateTime>()) .Returns(CalendarInteractor); InteractorFactory .GetDefaultWorkspace() .Execute() .Returns(Observable.Return(workspace)); InteractorFactory .CreateTimeEntry(Arg.Any <ITimeEntryPrototype>()) .Execute() .Returns(Observable.Return(timeEntry)); InteractorFactory .UpdateTimeEntry(Arg.Any <EditTimeEntryDto>()) .Execute() .Returns(Observable.Return(timeEntry)); }
public void Execute(IInteractor interaction) { Task.Factory.StartNew(interaction.Execute, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default); }
public void Start(IInteractor interactor) { interactor.SendOutput("Encryptor started. Enter command:"); var command = interactor.RecieveInput(); while (command != "stop encryptor") { if (!string.IsNullOrEmpty(command)) { try { CommandProcessor.Instance(interactor).ProcessCommand(command); } catch (FileNotFoundException) { interactor.SendOutput("File not found."); } catch (Exception ex) { interactor.SendOutput(ex.ToString()); } } else { interactor.SendOutput(@"Unknown command. Type ""help"" for a list of commands."); } interactor.SendOutput("Enter command:"); command = interactor.RecieveInput(); } interactor.SendOutput("Encryptor stoped."); }
internal void ForwardSubscription(IInteractor subscriber, SubscriptionRequest subscriptionRequest) { // Find all the interactors that wish to be notified of subscriptions to this topic. var notifiables = _repository.FindNotifiables(subscriptionRequest.Feed); if (notifiables == null) { return; } var forwardedSubscriptionRequest = new ForwardedSubscriptionRequest(subscriber.User, subscriber.Address, subscriber.Id, subscriptionRequest.Feed, subscriptionRequest.Topic, subscriptionRequest.IsAdd); Log.Debug($"Notifying interactors[{string.Join(",", notifiables)}] of subscription {forwardedSubscriptionRequest}"); // Inform each notifiable interactor of the subscription request. foreach (var notifiable in notifiables) { try { notifiable.SendMessage(forwardedSubscriptionRequest); } catch (Exception exception) { Log.Debug($"Failed to notify {notifiable} regarding {forwardedSubscriptionRequest}", exception); } } }
public void FaultInteractor(IInteractor interactor, Exception error) { Log.Info($"Faulting interactor: {interactor}"); _repository.Remove(interactor); FaultedInteractors?.Invoke(this, new InteractorFaultedEventArgs(interactor, error)); }
public void CloseInteractor(IInteractor interactor) { Log.Info($"Closing interactor: {interactor}"); _repository.Remove(interactor); ClosedInteractors?.Invoke(this, new InteractorClosedEventArgs(interactor)); }
public InteractorWithMouseButtonDownFilter( IInteractor wrappee, MouseButtonFlags mouseDownButtonFlags) : base(wrappee) { this.mouseButtonFlags_0 = mouseDownButtonFlags; }
public void Interact(IInteractor interactor) { switch (CurrentState) { case State.Empty: if (interactor.CurrentItem is null) { return; } if (string.IsNullOrWhiteSpace(ItemRequestID) || ItemRequestID.ToLower() == interactor.CurrentItem.ID.ToLower()) { Product = interactor.CurrentItem.GameObject; interactor.DropItem(); Product.transform.SetParent(this.transform); Product.transform.position = ResultPoint.transform.position; Product.transform.rotation = ResultPoint.transform.rotation; CurrentState = State.Filled; } break; case State.Filled: if (RemainingHitCount > 0) { UIfiller.transform.parent.gameObject.SetActive(true); RemainingHitCount -= 1; Debug.Log(RemainingHitCount / DefaultHealthValue); UIfiller.fillAmount = 1 - (RemainingHitCount / DefaultHealthValue); } else { UIfiller.transform.parent.gameObject.SetActive(false); CurrentState = State.Ready; Destroy(Product); if (ResultProduct is null || ResultProduct.tag != "interactable") { return; } resultInteractable = Instantiate(ResultProduct, ResultPoint.transform.position, ResultPoint.transform.rotation).GetComponent <IInteractable>(); CurrentState = State.Ready; } break; case State.Ready: resultInteractable.Interact(interactor); CurrentState = State.Completed; break; case State.Completed: break; } }
private void DoInteract(SimulationComponent simulation, IInteractor interactor, IInteractable interactable) { var quest = simulation.World.Quests.SingleOrDefault(q => q.Name == "Heidis Quest"); before.Visible = quest.State == QuestState.Inactive; after.Visible = quest.State == QuestState.Active && quest.CurrentProgress.Id == "return"; RheinwerkGame game = simulation.Game as RheinwerkGame; simulation.ShowInteractionScreen(interactor as Player, new DialogScreen(game.Screen, this, interactor as Player, dialog)); }
private void interactor_Deactivated(object sender, EventArgs e) { if (interactor != null) { interactor.Deactivated -= new EventHandler(interactor_Deactivated); interactor = null; fishNetGraphics3D.Clear(); fishNetGraphics3D.CreateDrawables(modelFishNet); polyGdiGraphics3D.Clear(); polyGdiGraphics3D.CreateDrawables(modelPoly); dynamicGdiGraphics3D.Clear(); Invalidate(); } }
private void DoInteract(SimulationComponent simulation, IInteractor interactor, IInteractable interactable) { RheinwerkGame game = simulation.Game as RheinwerkGame; simulation.ShowInteractionScreen(interactor as Player, new ShoutScreen(game.Screen, this, "Bleib ein Weilchen und hoer zu!")); }
public void StartInteraction(IInteractor interactor, IInteractorWinFormsDrawable interactorDrawable) { if (interactor != null) { this.interactor = interactor; this.interactorDrawable = interactorDrawable; interactor.Deactivated += interactor_Deactivated; interactor.Activate(); } }