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


C# IMessageBus.Listen方法代码示例

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


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

示例1: PasteViewModel

        public PasteViewModel(ClipboardItem clipboardItem, IRoom room, IMessageBus bus)
        {
            if (clipboardItem.IsImage)
            {
                _imageSource = clipboardItem.LocalPath;
            }
            else
            {
                _imageSource = DependencyProperty.UnsetValue;
            }

            Caption = "Upload this " + (clipboardItem.IsImage ? "image" : "file") + "?";
            LocalPath = clipboardItem.LocalPath;
            ShowLocalPath = !clipboardItem.IsImage;
            ContentType = clipboardItem.ContentType;
            Size = clipboardItem.Size;

            PasteCommand = new ReactiveCommand();

            Subscribe(bus.Listen<FileUploadedMessage>().Where(msg => msg.CorrelationId == _currentCorrelation)
                .SubscribeUI(_ => IsFinished = true));

            Subscribe(bus.Listen<FileUploadProgressChangedMessage>().Where(msg => msg.CorrelationId == _currentCorrelation)
                .SubscribeUI(
                    msg =>
                    {
                        ProgressCurrent = msg.Progress.Current;
                        ProgressTotal = msg.Progress.Total;
                        Debug.WriteLine("Current, total" + ProgressCurrent + ", " + ProgressTotal);
                    }));

            Subscribe(bus.Listen<CorrelatedExceptionMessage>().Where(msg => msg.CorrelationId == _currentCorrelation)
                .SubscribeUI(msg =>
                    {
                        IsErrored = true;
                        IsUploading = false;
                        LastException = msg.Exception;
                    }));

            ProgressCurrent = 0;
            ProgressTotal = 100;

            Subscribe(bus.RegisterMessageSource(
                PasteCommand.Do(_ =>
                    {
                        IsUploading = true;
                        IsErrored = false;
                    })
                .Select(_ => new RequestUploadFileMessage(room.Id, clipboardItem.LocalPath, clipboardItem.ContentType))
                .Do(msg => _currentCorrelation = msg.CorrelationId)));

            CancelCommand = new ReactiveCommand();
            Subscribe(CancelCommand.Subscribe(_ => IsFinished = true));
        }
开发者ID:Doomblaster,项目名称:MetroFire,代码行数:54,代码来源:PasteViewModel.cs

示例2: Register

        public void Register(IMessageBus bus)
        {
            // Listen for the message which attaches a frame.
            bus.Listen<ApplicationInitializedMessage>()
               .ObserveOn(RxApp.DeferredScheduler)
               .Subscribe(s => Frame = s.RootFrame);

            // Listen for the message which attaches a popup host.
            bus.Listen<PopupHostReadyMessage>()
               .ObserveOn(RxApp.DeferredScheduler)
               .Subscribe(m => PopupHost = m.PopupHost);
        }
开发者ID:anurse,项目名称:AppRT,代码行数:12,代码来源:HostService.cs

示例3: ShellView

        public ShellView(IShellViewModel vm, IMessageBus bus, IModuleResolver resolver, ISettings settings)
            : this()
        {
            _bus = bus;
            _resolver = resolver;
            _settings = settings;
            DataContext = vm;

            _bus.Listen<ActivateMainModuleMessage>().Subscribe(msg => ActivateMainModule(msg.ModuleName));
            _bus.Listen<NavigateMainModuleMessage>().Subscribe(msg => NavigateMainModule(msg.ModuleName));
            _bus.Listen<NavigateBackMainModuleMessage>().Where(_ => _navigationStack.Count > 0).Subscribe(
                _ => NavigateBack());

            _bus.Listen<SettingsChangedMessage>().Subscribe(OnSettingsChanged);
        }
开发者ID:Doomblaster,项目名称:MetroFire,代码行数:15,代码来源:ShellView.xaml.cs

示例4: Register

 public void Register(IMessageBus bus)
 {
     // Listen for the message which has us navigate.
     bus.Listen<NavigateMessage>()
        .ObserveOn(RxApp.DeferredScheduler)
        .Subscribe(OnNavigateMessage);
 }
开发者ID:anurse,项目名称:AppRT,代码行数:7,代码来源:NavigationService.cs

示例5: ModuleLoader

        public ModuleLoader(IMessageBus bus, IWindsorContainer windsorContainer)
        {
            _bus = bus;
            _windsorContainer = windsorContainer;

            _bus.Listen<ApplicationLoadedMessage>().ObserveOn(Scheduler.ThreadPool).Subscribe(OnApplicationLoaded);
        }
开发者ID:ArildF,项目名称:Core,代码行数:7,代码来源:ModuleLoader.cs

示例6: LoanViewModel

        public LoanViewModel(IMessageBus messenger, Loan loan)
        {
            myLoan = loan;
            _OweTo = myLoan.Lender.Name;
            _APR = myLoan.APR;
            _OutstandingBalance = myLoan.OutstandingBalance(DateTime.Now);

            _MakePaymentCommand = new DelegateCommand(MakePaymentExecute, MakePaymentCanExecute);

            myMessenger = messenger;
            myMessenger
                .Listen<Loan>("PaymentMade")
                .ObserveOnDispatcher()
                .Subscribe(
                    l =>
                    {
                        if (l == myLoan)
                        {
                            myMessenger.SendMessage<Person>(loan.Lender, "BalanceChanged");
                            myMessenger.SendMessage<Person>(loan.Borrower, "BalanceChanged");
                            this.PaymentMaker = null;
                            this.OutstandingBalance = myLoan.OutstandingBalance(DateTime.Now);
                        }
                    });
        }
开发者ID:Aesir,项目名称:LoanTracker,代码行数:25,代码来源:LoanViewModel.cs

示例7: NewImageVM

        public NewImageVM(IMessageBus Messenger,
            IStoreImages ImageStore) {
            Messenger.Listen<IElementVM<MultimediaObject>>(MessageContracts.EDIT)
                .Where(vm => vm.Model.MediaType == MediaType.Image && vm.Model.IsNew())
                .SelectMany(mmo => {
                        var capture = new CameraCaptureTask();
                        var results =
                            Observable.FromEventPattern<PhotoResult>(h => capture.Completed += h, h => capture.Completed -= h)
                            .Select(ev => ev.EventArgs)
                            .Catch(Observable.Empty<PhotoResult>())
                            .Select(res => new { VM = mmo, Result = res })
                            .Take(1)
                            .Replay(1);
                        results.Connect();
                        try {
                            capture.Show();
                        }
                        catch (InvalidOperationException) {
                        }
                        return results;
                    })
                .Where(tuple => tuple.VM != null
                    && tuple.Result != null
                    && tuple.Result.TaskResult == TaskResult.OK)
                .Do(tuple => {
                        tuple.VM.Model.Uri = ImageStore.StoreImage(tuple.VM.Model.NewFileName(), tuple.Result);

                    })
                .Select(t => t.VM as IElementVM<MultimediaObject>)
                .ToMessage(Messenger, MessageContracts.SAVE);
        }
开发者ID:rollingthunder,项目名称:DiversityMobile,代码行数:31,代码来源:NewImageVM.cs

示例8: SubscribeToMessageBus

 public void SubscribeToMessageBus(IMessageBus messageBus)
 {
     if (this.subscription == null)
     {
         this.subscription = messageBus.Listen<object>().Subscribe(this.SubscriptionHandler);
     }
 }
开发者ID:ArturPhilibin,项目名称:ReactiveUiMessageBusMemoryTests,代码行数:7,代码来源:ViewModel.cs

示例9: NavigationContentViewModel

        public NavigationContentViewModel(ISettingsViewModel settingsViewModel, IMessageBus bus)
        {
            _settingsViewModel = settingsViewModel;
            bus.Listen<AppUpdateAvailableMessage>().SubscribeOnceUI(_ =>
                {
                    ShowUpdate = true;
                });
            bus.Listen<AppUpdateProgressMessage>().SubscribeUI(msg =>
                {
                    ShowProgress = true;
                    ShowUpdate = false;
                    ProgressValue = msg.ProgressPercentage;
                });

            StartUpdateCommand = new ReactiveCommand();
            bus.RegisterMessageSource(StartUpdateCommand.Select(c => new RequestAppUpdateMessage()));
        }
开发者ID:Doomblaster,项目名称:MetroFire,代码行数:17,代码来源:NavigationContentViewModel.cs

示例10: ModuleViewModel

        public ModuleViewModel(IModule module, IMessageBus bus)
        {
            _module = module;
            _bus = bus;

            _bus.Listen<RoomActivityMessage>().Delay(TimeSpan.FromMilliseconds(100))
                .SubscribeUI(msg => this.RaisePropertyChanged(vm => vm.Notifications));
        }
开发者ID:Doomblaster,项目名称:MetroFire,代码行数:8,代码来源:ModuleViewModel.cs

示例11: ShellViewModel

        public ShellViewModel(IMainScreen mainScreen, IMessageBus bus)
        {
            _navigationStack.Push(mainScreen);

            bus.Listen<NavigateMainModuleMessage>().SubscribeUI(msg => NavigateTo(msg.Module.MainViewModel));

            NavigateBackCommand = new ReactiveCommand();
            NavigateBackCommand.SubscribeUI(NavigateBack);
        }
开发者ID:ArildF,项目名称:Core,代码行数:9,代码来源:ShellViewModel.cs

示例12: ShellViewModel

        public ShellViewModel(IMessageBus bus)
        {
            Title = DefaultTitle;

            var activated = bus.Listen<ApplicationActivatedMessage>();
            var deactivated = bus.Listen<ApplicationDeactivatedMessage>();

            bus.Listen<RoomActivityMessage>()
                .SkipUntil(deactivated)
                .TakeUntil(activated.Do(_ => UnreadCount = 0))
                .Repeat()
                .Subscribe(_ => UnreadCount++);

            bus.Listen<RequestApplicationRestartMessage>().ObserveOnDispatcher().Subscribe(_ =>
                {
                    System.Windows.Forms.Application.Restart();
                    Environment.Exit(1);
                });
        }
开发者ID:Doomblaster,项目名称:MetroFire,代码行数:19,代码来源:ShellViewModel.cs

示例13: ToastWindowViewModel

        public ToastWindowViewModel(Func<IChatDocument> chatDocumentCreator, IMessageBus bus, IApplicationActivator activator)
        {
            _chatDocumentCreator = chatDocumentCreator;
            _bus = bus;
            _activator = activator;

            Toasts = new ReactiveCollection<ToastViewModel>();

            Subscribe(() => bus.Listen<ShowToastMessage>().SubscribeUI(OnShowToast));
        }
开发者ID:Doomblaster,项目名称:MetroFire,代码行数:10,代码来源:ToastWindowViewModel.cs

示例14: RoomListViewModel

        public RoomListViewModel(Room room, IMessageBus bus)
        {
            _room = room;
            _bus = bus;

            bus.Listen<RoomPresenceMessage>().SubscribeUI(msg => IsActive = msg.IsPresentIn(_room.Id));

            _bus.Listen<RoomActivatedMessage>().Where(msg => msg.RoomId == _room.Id)
                .Do(_ => IsJoiningRoom = false)
                .SubscribeUI(_ => IsCurrentRoom = true);

            _bus.Listen<RoomDeactivatedMessage>().Where(msg => msg.RoomId == _room.Id)
                .SubscribeUI(_ => IsCurrentRoom = false);

            _bus.Listen<RoomActivityMessage>().Where(msg => msg.RoomId == _room.Id)
                .SubscribeUI(msg => RoomActivityCount += msg.Count);

            JoinCommand = new ReactiveCommand();
            JoinCommand.Do(_ => IsJoiningRoom = true).SubscribeUI(HandleJoinCommand);
        }
开发者ID:Doomblaster,项目名称:MetroFire,代码行数:20,代码来源:RoomListViewModel.cs

示例15: MainCampfireView

        public MainCampfireView(IMainCampfireViewModel model, IMessageBus bus, INavigationContent content)
            : this()
        {
            _bus = bus;
            _content = content;
            _model = model;
            DataContext = model;

            bus.Listen<ActivateModuleMessage>()
                .Where(msg => msg.ParentModule == ModuleNames.MainCampfireView)
                .Where(msg => msg.Module != _moduleContainer.Content)
                .SubscribeUI(ActivateModule);
        }
开发者ID:Doomblaster,项目名称:MetroFire,代码行数:13,代码来源:MainCampfireView.xaml.cs


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