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


C# EventAggregator类代码示例

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


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

示例1: ServiceFactoryBase

		static ServiceFactoryBase()
		{
			Events = new EventAggregator();
			ResourceService = new ResourceService();
			DialogService = new RealDialogService();
			MessageBoxService = new RealMessageBoxService();
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:7,代码来源:ServiceFactoryBase.cs

示例2: App

        public App()
        {
            try
            {
                IUnityContainer unityContainer = new UnityContainer();

                var connectionString = System.Configuration.ConfigurationSettings.AppSettings.Get("webService");
                IWebservice webService = new Webservice(connectionString);

                EventAggregator eventAggregator = new EventAggregator();
                unityContainer.RegisterInstance<IEventAggregator>(eventAggregator);
                unityContainer.RegisterInstance<IWebservice>(webService);

                IMessaging emailMessenger = new EmailMessaging();
                unityContainer.RegisterInstance<IMessaging>(emailMessenger);

                var regionManager = new RegionManager();
                regionManager.Regions.Add(new Region() { Name = "MainContentRegion" });
                unityContainer.RegisterInstance<IRegionManager>(regionManager);

                ServiceLocator.SetLocatorProvider(() => new UnityServiceLocator(unityContainer));

            }
            catch (Exception ex)
            {
                logger.Error("Error in app constructor", ex);
            }
        }
开发者ID:SoulForging,项目名称:CoolBlue,代码行数:28,代码来源:App.xaml.cs

示例3: a_published_message_is_received_by_multiple_subscribers

        public void a_published_message_is_received_by_multiple_subscribers()
        {
            // When the bus publishes a message, it is sent through the socket
            var consumer = new ZeroConsumer<Message>("tcp://localhost:5562");
            var bus = new BusAdapter();
            bus.AttachConsumer(consumer);

            // Meanwhile, the aggregator waits for messages from the same socket
            var producer = new ZeroProducer<Message>("tcp://*:5562");
            var aggregator = new EventAggregator<Message>();
            aggregator.AttachTo(producer);

            // While two test consumers are subscribed to the aggregator
            // (the syntax looks like it's the other way around)
            var confirmById = new FakeEventConsumer();
            var confirmAsReceived = new TestConsumer();
            aggregator.SubscribeTo(confirmById);
            aggregator.SubscribeTo(confirmAsReceived);

            // When we drop a message on the bus, the test consumer should get it
            var @event = new FakeEvent();
            bus.Publish(@event);

            // Pause the thread so the producer (via aggregator) can send to the test consumer
            var timeout = TimeSpan.FromSeconds(1).TotalMilliseconds;
            Thread.Sleep((int)timeout);

            Assert.IsTrue(confirmAsReceived.Received);
            Assert.AreEqual(@event.Id, confirmById.Id);

            producer.Dispose();
            consumer.Dispose();
        }
开发者ID:thefringeninja,项目名称:Event-handling,代码行数:33,代码来源:When_using_bus.cs

示例4: Given

 protected override void Given()
 {
     eventAggregator = new EventAggregator();
     view = new Mock<ITerritoryStatsView>();
     territoryStats = new TerritoryStatsPresentationModel(
         view.Object, eventAggregator);
 }
开发者ID:trasa,项目名称:cabal,代码行数:7,代码来源:TerritoryStatsPresentationModelFixture.cs

示例5: ActivityFinderPopupViewModel

        public ActivityFinderPopupViewModel(BcontrolDataHandler datahandler,C1DataGrid searchGrid)
        {
            eventaggregator = EventAggregator.Instance;
            IsVisible = false;
            _datahandler = datahandler;
            _datahandler.SearchInitialDataRetrieved += new EventHandler<GetSearchInitialDataCompletedEventArgs>(bcontrolDataHandler_SearchInitialDataRetrieved);
            _datahandler.SearchByMapListRetrieved +=new EventHandler<GetSearchMapListCompletedEventArgs>(bcontrolDatahandler_SearchByMapListRetrieved);
            _datahandler.SearchByGlobalHeadListRetrieved += new EventHandler<GetSearchGlobalHeadListCompletedEventArgs>(bcontrolDatahandler_SearchByGlobalHeadListRetrieved);
            _datahandler.SearchByGlobalFunctionListRetrieved += new EventHandler<GetSearchGlobalFunctionListCompletedEventArgs>(bcontrolDatahandler_SearchByGlobalFunctionListRetrieved);
            _datahandler.SearchByBusinessAreaListRetrieved += new EventHandler<GetSearchBusinessAreaListCompletedEventArgs>(bcontrolDatahandler_SearchByBusinessAreaListRetrieved);
            _datahandler.SearchByBusinessFunctionListRetrieved += new EventHandler<GetSearchBusinessFunctionListCompletedEventArgs>(bcontrolDatahandler_SearchByBusinessFunctionListRetrieved);
            _datahandler.SearchBySubFunctionListRetrieved += new EventHandler<GetSearchSubFunctionListCompletedEventArgs>(bcontrolDatahandler_SearchByBusinessSubFunctionListRetrieved);

            _datahandler.SearchByLevelDataRetrieved += new EventHandler<GetSearchResultsBylevelCompletedEventArgs>(bcontrolDataHandler_SearchByLevelDataRetrieved);
            _datahandler.SearchByHierarchyDataRetrieved += new EventHandler<GetSearchResultsByHierarchyCompletedEventArgs>(bcontrolDataHandler_SearchByHierarchyDataRetrieved);
            _datahandler.DiagramTemplateLinkRetrieved += new EventHandler<GetDiagramTemplateLinkCompletedEventArgs>(bcontrolDataHandler_DiagramTemplateLinkRetrieved);
            _datahandler.ExisitingActivitiesRetrieved +=new EventHandler<GetExisitingActivitiesCompletedEventArgs>(bcontrolDatahandler_ExisitingActivitiesRetrieved);            

            _isModifiedLinks = false;
         
            _searchResultsList = new ObservableCollection<ActivitySet>();
            _datahandler.GetDiagramTemplateLink();

            ErrorMessage = "";

            _searchGrid = searchGrid;
        }              
开发者ID:nilavghosh,项目名称:VChk,代码行数:27,代码来源:ActivityfinderPopupViewModel.cs

示例6: OnStartup

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            RegisterServices();
            EventAggregator = new EventAggregator();
        }
开发者ID:CNinnovation,项目名称:WPFWorkshop,代码行数:7,代码来源:App.xaml.cs

示例7: UploadReportHierarchyViewModel

        public UploadReportHierarchyViewModel(StringBuilder log, C1DataGrid grid, BcontrolDataHandler bcontrolDataHandler)
        {
            eventaggregator = EventAggregator.Instance;
            _log = log;
            _grid = grid;

            PreviewCommand = new RelayCommand(PreviewAction);
            PreviewCommand.IsEnabled = false;
            UploadCommand = new RelayCommand(UploadAction);
            UploadCommand.IsEnabled = false;

            CloseCommand = new RelayCommand(CloseAction);
            CloseCommand.IsEnabled = true;

            _datahandler = bcontrolDataHandler;

            _datahandler.ClearBcontrolHierarchyDataRetrieved += new EventHandler<ClearBcontrolHierarchyDataCompletedEventArgs>(_datahandler_ClearBcontrolHierarchyDataRetrieved);
            _datahandler.AddBcontrolHierarchyDataRetrieved += new EventHandler<AddBcontrolHierarchyDataCompletedEventArgs>(_datahandler_AddBcontrolHierarchyDataRetrieved);
            _datahandler.CompleteAddBcontrolHierarchyDataRetrieved += new EventHandler<CompleteAddBcontrolHierarchyDataCompletedEventArgs>(_datahandler_CompleteAddBcontrolHierarchyDataRetrieved);

            _columns = new Dictionary<string, ReportField>();
            
            _columns.Add("Map Name", new ReportField(100, true));
            _columns.Add("Level", new ReportField(500, true));
            _columns.Add("FunctionalHead", new ReportField(50, false));
            _columns.Add("AdditionalData", new ReportField(100, false));
            _columns.Add("TOM", new ReportField(100, false));
            _columns.Add("REN", new ReportField(100, false));
            _columns.Add("Bcontrol Function Structure", new ReportField(100, false));
            _columns.Add("Taxonomy Level 3", new ReportField(100, false));
            _columns.Add("BusinessHierarchy1", new ReportField(100, false));
            _columns.Add("BusinessHierarchy2", new ReportField(100, false));
            _columns.Add("BusinessHierarchy3", new ReportField(100, false));

        }
开发者ID:nilavghosh,项目名称:VChk,代码行数:35,代码来源:UploadReportHierarchyViewModel.cs

示例8: 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

示例9: TryGetEventHandler_should_return_false_when_no_subscribers_exist

        public void TryGetEventHandler_should_return_false_when_no_subscribers_exist()
        {
            var subject = new EventAggregator();

            Action<int> handler;
            subject.TryGetEventHandler(out handler).Should().BeFalse();
        }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:7,代码来源:EventAggregatorTests.cs

示例10: ObserverShouldOnlyReceiveSubscribedNotifications

        public void ObserverShouldOnlyReceiveSubscribedNotifications()
        {
            // Arrange

            var eventAggregator = new EventAggregator();
            var observer1 = new Mock<IObserve<TestEvent>>();
            var observer2 = new Mock<IObserve<OtherEvent>>();

            eventAggregator.Subscribe(observer1.Object);
            eventAggregator.Subscribe(observer2.Object);

            var testEvent = new TestEvent();
            var otherEvent = new OtherEvent();

            // Act

            eventAggregator.Publish(testEvent);
            eventAggregator.Publish(otherEvent);

            // Assert

            observer1.Verify(x => x.OnNext(It.IsAny<IEvent>()), Times.Once);
            observer1.Verify(x => x.OnNext(testEvent), Times.Once);
            observer2.Verify(x => x.OnNext(otherEvent), Times.Once);
        }
开发者ID:phdesign,项目名称:EventAggregator,代码行数:25,代码来源:EventAggregatorTests.cs

示例11: Navigate_To_Subsequent_Page_Back_Button_Visible

        public async Task Navigate_To_Subsequent_Page_Back_Button_Visible()
        {
            await DispatcherHelper.ExecuteOnUIThread(() =>
            {
                var eventAggregator = new EventAggregator();
                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);
                var deviceGestureService = new DeviceGestureService(eventAggregator);
                deviceGestureService.UseTitleBarBackButton = true;
                var navigationManager = SystemNavigationManager.GetForCurrentView();

                // Reset back button visibility before running, can't do this in TestInitialize because CoreWindow sometimes isn't ready
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;

                Assert.AreEqual(AppViewBackButtonVisibility.Collapsed, navigationManager.AppViewBackButtonVisibility);

                navigationService.Navigate("Mock", 1);

                Assert.AreEqual(AppViewBackButtonVisibility.Collapsed, navigationManager.AppViewBackButtonVisibility);

                navigationService.Navigate("Mock", 2);

                Assert.AreEqual(AppViewBackButtonVisibility.Visible, navigationManager.AppViewBackButtonVisibility);
            });
        }
开发者ID:Citringo,项目名称:Prism,代码行数:27,代码来源:DeviceGestureServiceFixture.cs

示例12: 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

示例13: A_valid_message_invokes_HandlerResultProcessing_when_expected_to

        public void A_valid_message_invokes_HandlerResultProcessing_when_expected_to() {
            var eventAggregator = new EventAggregator();
            var coroutineHandlerMock = new Mock<IHandleWithCoroutine<object>>();
            var taskHandlerMock = new Mock<IHandleWithTask<object>>();
            var coroutineHandlerProcessed = false;
            var taskHandlerProcessed = false;

            coroutineHandlerMock.Setup(handlerStub => handlerStub.Handle(It.IsAny<object>()))
                                .Returns(() => new List<IResult>());

            taskHandlerMock.Setup(handlerStub => handlerStub.Handle(It.IsAny<object>()))
                           .Returns(() => new Task(() => { }));

            EventAggregator.HandlerResultProcessing = (target, result) => {

                if (target is IHandleWithCoroutine<object>) {
                    coroutineHandlerProcessed = true;
                }
                else if (target is IHandleWithTask<object>) {
                    taskHandlerProcessed = true;
                }
            };

            eventAggregator.Subscribe(coroutineHandlerMock.Object);
            eventAggregator.Subscribe(taskHandlerMock.Object);
            eventAggregator.Publish(new object());

            Assert.True(coroutineHandlerProcessed);
            Assert.True(taskHandlerProcessed);
        }
开发者ID:yan122725529,项目名称:SqlComPare_Mvvm,代码行数:30,代码来源:EventAggregatorTests.cs

示例14: 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

示例15: MainViewModel

 public MainViewModel()
 {
     var events = new EventAggregator();
     var config = new Configuration(events: events).WithCss().WithDefaultLoader(m => 
     {
         m.IsNavigationEnabled = true;
         m.IsResourceLoadingEnabled = true;
     });
     context = BrowsingContext.New(config);
     profiler = new ProfilerViewModel(events);
     errors = new ErrorsViewModel(events);
     dom = new DOMViewModel();
     query = new QueryViewModel();
     repl = new ReplViewModel();
     settings = new SettingsViewModel();
     statistics = new StatisticsViewModel();
     tree = new TreeViewModel();
     sheets = new SheetViewModel();
     cts = new CancellationTokenSource();
     views = new ITabViewModel[] 
     {
         dom,
         query,
         repl,
         statistics,
         tree,
         sheets
     };
     logs = new IEventViewModel[]
     {
         profiler,
         errors
     };
 }
开发者ID:Aurylius,项目名称:AngleSharp.Samples,代码行数:34,代码来源:MainViewModel.cs


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