当前位置: 首页>>代码示例>>C#>>正文


C# EventAggregator.GetEvent方法代码示例

本文整理汇总了C#中EventAggregator.GetEvent方法的典型用法代码示例。如果您正苦于以下问题:C# EventAggregator.GetEvent方法的具体用法?C# EventAggregator.GetEvent怎么用?C# EventAggregator.GetEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventAggregator的用法示例。


在下文中一共展示了EventAggregator.GetEvent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShouldPassOnTheHintFromTheFirstHelpfulRule

        public void ShouldPassOnTheHintFromTheFirstHelpfulRule()
        {
            // Given an event aggregator to which we're subscribed
            var events = new EventAggregator();
            Hint hint = null;
            events.GetEvent<HintProvidedEvent>().Subscribe(h => hint = h);

            // And one rule which fails then one which passes first time
            var unhelpfulRule = new Mock<IMightBeAbleToHelp>();
            unhelpfulRule.Setup(r => r.HelpWith(It.IsAny<NineCells>())).Returns(Hint.None);

            var expectedHint = new Hint("I can help!", new List<Cell>());
            var helpfulRule = new Mock<IMightBeAbleToHelp>();
            helpfulRule.Setup(r => r.HelpWith(It.IsAny<NineCells>())).Returns(expectedHint);

            // And a repository with some cells in it
            var repository = new Mock<ILookAfterCells>();
            repository.Setup(r => r.FetchCellsByRowColumnOrNiner()).Returns(
                new List<NineCells> {new NineCells(new Cell[0])});

            // When we publish a request for a hint
            new Solver(events, repository.Object, new[] {unhelpfulRule.Object, helpfulRule.Object});
            events.GetEvent<HintRequestEvent>().Publish(null);

            // Then the solver should publish the first helpful hint
            Assert.AreEqual(expectedHint, hint);
        }
开发者ID:powerdude,项目名称:sudoque,代码行数:27,代码来源:SolverBehavior.cs

示例2: GetReturnsSingleInstancesOfSameEventType

        public void GetReturnsSingleInstancesOfSameEventType()
        {
            var eventAggregator = new EventAggregator();
            var instance1 = eventAggregator.GetEvent<MockEventBase>();
            var instance2 = eventAggregator.GetEvent<MockEventBase>();

            Assert.AreSame(instance2, instance1);
        }
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:8,代码来源:EventAggregatorFixture.cs

示例3: Create

 public static CodeFlowService Create(ConfigurationService configurationService, EventAggregator eventAggregator)
 {
     var authorWatch = configurationService["AuthorWatch"];
     var secondAuthorWatch = configurationService["SecondAuthorWatch"];
     var refreshInterval = int.Parse(configurationService["RefreshInterval"]);
     var announceInterval = int.Parse(configurationService["AnnounceInterval"]);
     var publishEventMessenger = eventAggregator.GetEvent<RawPublishEvent>();
     var traceEventMessenger = eventAggregator.GetEvent<TraceEvent>();
     return new CodeFlowService(authorWatch, secondAuthorWatch, refreshInterval, announceInterval, publishEventMessenger, traceEventMessenger);
 }
开发者ID:joshjcarrier,项目名称:EventPipe,代码行数:10,代码来源:CodeFlowService.cs

示例4: Create

 public static TfsClientService Create(ConfigurationService configurationService, EventAggregator eventAggregator)
 {
     var projectCollectionUrl = configurationService["ProjectCollectionUrl"];
     var projectName = configurationService["ProjectName"];
     var serverCountQueries = configurationService.Where(p => p.Key.StartsWith("query", StringComparison.OrdinalIgnoreCase)).Select(p => p.Value);
     var refreshInterval = int.Parse(configurationService["RefreshInterval"]);
     var nextInterval = int.Parse(configurationService["NextInterval"]);
     var publishEventMessenger = eventAggregator.GetEvent<RawPublishEvent>();
     var traceEventMessenger = eventAggregator.GetEvent<TraceEvent>();
     return new TfsClientService(projectCollectionUrl, projectName, serverCountQueries, refreshInterval, nextInterval, publishEventMessenger, traceEventMessenger);
 }
开发者ID:joshjcarrier,项目名称:EventPipe,代码行数:11,代码来源:TfsClientService.cs

示例5: Navigate_Raises_NavigationStateChangedEvent

        public async Task Navigate_Raises_NavigationStateChangedEvent()
        {
            var tcs = new TaskCompletionSource<bool>();
            var eventAggregator = new EventAggregator();

            eventAggregator.GetEvent<NavigationStateChangedEvent>().Subscribe((args) => tcs.SetResult(args.StateChange == StateChangeType.Forward));

            await DispatcherHelper.ExecuteOnUIThread(() =>
            {
                var frame = new FrameFacadeAdapter(new Frame(), eventAggregator);
                var sessionStateService = new MockSessionStateService();
                sessionStateService.GetSessionStateForFrameDelegate = (currentFrame) => new Dictionary<string, object>();
                var navigationService = new FrameNavigationService(frame, (pageToken) => typeof(MockPage), sessionStateService);

                navigationService.Navigate("Mock", 1);
            });

            await Task.WhenAny(tcs.Task, Task.Delay(200));

            if (tcs.Task.IsCompleted)
            {
                Assert.IsTrue(tcs.Task.Result);
            }
            else
            {
                Assert.Fail("NavigationStateChangedEvent event wasn't raised within 200 ms.");
            }
        }
开发者ID:Citringo,项目名称:Prism,代码行数:28,代码来源:FrameFacadeAdapterFixture.cs

示例6: ShouldAskEachRuleInTurnWithNinersRowsAndColumnsUntilOnePasses

        public void ShouldAskEachRuleInTurnWithNinersRowsAndColumnsUntilOnePasses()
        {
            // Given a repository with different rows, columns and niners
            var niners = new List<NineCells> { new NineCells( new[] {new Cell(new CellId(-1, -1)) } )};
            var rows = new List<NineCells> { new NineCells( new[] {new Cell(new CellId(-1, -1)) } )};
            var columns = new List<NineCells>
                              {
                                  new NineCells(new[] {new Cell(new CellId(-1, -1))} ),
                                  new NineCells(new[] {new Cell(new CellId(-1, -1))} ),
                                  new NineCells(new[] {new Cell(new CellId(-1, -1))} ),
                              };

            var repository = new Mock<ILookAfterCells>();
            var allSequences = new[] {niners, rows, columns}.SelectMany(list => list).ToArray();
            repository.Setup(r => r.FetchCellsByRowColumnOrNiner()).Returns(allSequences);

            // And one rule which fails then one which passes first time
            var unhelpfulRule = new Mock<IMightBeAbleToHelp>();
            unhelpfulRule.Setup(r => r.HelpWith(It.IsAny<NineCells>())).Returns(Hint.None);

            var expectedHint = new Hint("I can help!", new List<Cell>());
            var helpfulRule = new Mock<IMightBeAbleToHelp>();
            helpfulRule.Setup(r => r.HelpWith(It.IsAny<NineCells>())).Returns(expectedHint);

            // When we ask the solver for a hint
            var events = new EventAggregator();
            new Solver(events, repository.Object, new[] {unhelpfulRule.Object, helpfulRule.Object});
            events.GetEvent<HintRequestEvent>().Publish(null);

            // Then the first rule should be called with each niner, row and column
            Array.ForEach(allSequences, s => unhelpfulRule.Verify(r => r.HelpWith(s)));

            // And the second should only be called once
            helpfulRule.Verify(r => r.HelpWith(It.IsAny<NineCells>()), Times.Once());
        }
开发者ID:powerdude,项目名称:sudoque,代码行数:35,代码来源:SolverBehavior.cs

示例7: Position

 public Position()
 {
     RemoveFromCollectionCommand = new DelegateCommand(RemoveFromCollection);
     GoToPositionCommand = new DelegateCommand(GoToPosition);
     ea = ServiceLocator.Current.GetInstance<EventAggregator>();
     ea.GetEvent<NewMicrostepResolutionEvent>()
         .Subscribe(onMicrostepResolutionChanged, ThreadOption.BackgroundThread);
 }
开发者ID:tvannuland,项目名称:AlgoLifter,代码行数:8,代码来源:Position.cs

示例8: OrderAndPositionViewModel

        public OrderAndPositionViewModel()
        {
            _eventaggregator = ServiceLocator.Current.GetInstance<EventAggregator>();
            _logger = ServiceLocator.Current.GetInstance<ILoggerFacade>();
            _configmanager = ServiceLocator.Current.GetInstance<IConfigManager>() as ConfigManager;

            _ordertracker = new OrderTracker(_configmanager.DailyOrderCapacity);
            _ordertracker.SendDebugEvent += OnDebug;
            _positiontracker = new PositionTracker(_configmanager.DailyOrderCapacity);

            _eventaggregator.GetEvent<InitialPositionEvent>().Subscribe(ClientGotInitialPosition);
            //_eventaggregator.GetEvent<SendOrderEvent>().Subscribe(ClientGotOrder);
            _eventaggregator.GetEvent<OrderConfirmationEvent>().Subscribe(ClientGotOrder);
            _eventaggregator.GetEvent<OrderCancelConfirmationEvent>().Subscribe(ClientGotOrderCancelConfirmation);
            _eventaggregator.GetEvent<OrderFillEvent>().Subscribe(ClientGotOrderFilled);
            _eventaggregator.GetEvent<GenerateReportEvent>().Subscribe(GeneratePerformanceReport);

            _resultstable.Columns.Add("Statistics");
            _resultstable.Columns.Add("Result");
        }
开发者ID:conradakunga,项目名称:QuantTrading,代码行数:20,代码来源:OrderAndPositionViewModel.cs

示例9: Subscribe_WhenGivenEvent_ShouldRaiseEvent

        public void Subscribe_WhenGivenEvent_ShouldRaiseEvent()
        {
            var eventWasRaised = false;
            var eventBus = new EventAggregator();

            eventBus.GetEvent<TestEvent>().Subscribe(new Observer<TestEvent>(x => eventWasRaised = true));

            eventBus.Publish(new TestEvent());

            Assert.IsTrue(eventWasRaised);
        }
开发者ID:dcga,项目名称:Reactive.EventAggregator.Net35,代码行数:11,代码来源:ConcurrentDictionaryTests.cs

示例10: InputService

        public InputService(EventAggregator eventAggregator, StandingsService standingsService)
        {
            _eventAggregator = eventAggregator;
            _standingsService = standingsService;

            _showEvent = _eventAggregator.GetEvent<ShowEvent>();
            _activePlayerChangedEvent = _eventAggregator.GetEvent<ActivePlayerChangedEvent>();
            _eventAggregator.GetEvent<ActivateEvent>().Subscribe(Activate);
            _eventAggregator.GetEvent<CloseEvent>().Subscribe(Reset);

            _buzz = new BuzzIOWrite.BuzzIOWrite();
            _buzz.FindTheHid();

            _players = new[] { false, false, false, false, false };
            _pressed = new[] { false, false, false, false, false };
            _used = new[] { false, false, false, false, false };

            _timeleft = TimeAvailable;
            _timer = new Timer(1000) { AutoReset = false };
            _timer.Elapsed += new ElapsedEventHandler(OnTimerEnd);
        }
开发者ID:ludoleif,项目名称:JeBuzzdy,代码行数:21,代码来源:InputService.cs

示例11: Unsubscribe_WhenGivenEvent_ShouldNotRaiseEvent

        public void Unsubscribe_WhenGivenEvent_ShouldNotRaiseEvent()
        {
            var eventWasRaised = false;
            var eventBus = new EventAggregator();

            var subscription = eventBus.GetEvent<TestEvent>().Subscribe(new Observer<TestEvent>(x => eventWasRaised = true));

            subscription.Dispose();
            eventBus.Publish(new TestEvent());

            Assert.IsFalse(eventWasRaised);
        }
开发者ID:dcga,项目名称:Reactive.EventAggregator.Net35,代码行数:12,代码来源:ConcurrentDictionaryTests.cs

示例12: testing_subscribe

        public void testing_subscribe()
        {
            // arrange
            var eventWasRaised = false;
            var eventPublisher = new EventAggregator();

            // act
            eventPublisher.GetEvent<SampleEvent>()
                .Subscribe(se => eventWasRaised = true);

            eventPublisher.Publish(new SampleEvent());
            
            // assert
            eventWasRaised.ShouldBe(true);
        }
开发者ID:shiftkey,项目名称:Reactive.EventAggregator,代码行数:15,代码来源:SimpleTests.cs

示例13: Main

        public static void Main(string[] args)
        {
            // Instantiate the Prism event aggregator and subscribe to events of type ISignalREvent. (Yes, their syntax is awful).
            var prismEventAggregator = new EventAggregator();
            prismEventAggregator.GetEvent<PubSubEvent<SimpleEvent>>().Subscribe(SimpleEventSubscriber);
            prismEventAggregator.GetEvent<PubSubEvent<ComplexEvent>>().Subscribe(ComplexEventSubscriber);

            // Prepare the connection.
            var hubConnection = new HubConnection("http://localhost:8700/");
            hubConnection.Error += ex =>
            {
                Console.WriteLine("SignalR error: {0}", ex.Message);
            };

            // Create and initialise our shim. Must be done before hubConnection.Start().
            var clientShim = new PrismEventAggregatorShim(prismEventAggregator);
            PubSubSignalRClient.Initialise(hubConnection, clientShim);

            // Connect.
            hubConnection.Start().Wait();

            Console.WriteLine("Client started! Press any key to stop...");
            Console.ReadKey();
        }
开发者ID:andyste1,项目名称:SignalR.PubSub,代码行数:24,代码来源:Program.cs

示例14: testing_selective_subscribe_ignored

        public void testing_selective_subscribe_ignored()
        {
            // arrange
            var eventWasRaised = false;
            var eventPublisher = new EventAggregator();

            // act
            eventPublisher.GetEvent<SampleEvent>()
                .Where(se => se.Status != 1)
                .Subscribe(se => eventWasRaised = true);

            eventPublisher.Publish(new SampleEvent { Status = 1 });

            // assert
            eventWasRaised.ShouldBe(false);
        }
开发者ID:shiftkey,项目名称:Reactive.EventAggregator,代码行数:16,代码来源:SimpleTests.cs

示例15: Progress_event

        public void Progress_event()
        {
            IEventAggregator aggregator = new EventAggregator();
            IFileDownloader downloader = new FileDownloader(aggregator);
            downloader.Initialize();
            var progressEvent = aggregator.GetEvent<UpdateProgressEvent>();

            int progressEventTimes = 0;

            progressEvent.Subscribe(state => progressEventTimes++);

            using (var file = downloader.Download(new Uri("http://www.google.co.nz/")))
            {
                Assert.IsNotNull(file);
                file.File.Refresh();
                Assert.IsTrue(file.File.Length > 0);
            }

            Assert.IsTrue(progressEventTimes > 0);
        }
开发者ID:DavidMoore,项目名称:BlocklistUpdater,代码行数:20,代码来源:FileDownloaderTests.cs


注:本文中的EventAggregator.GetEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。