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


C# IMessageBus.SendMessage方法代码示例

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


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

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

示例2: RefreshVocabularyVM

        public RefreshVocabularyVM(
            ICredentialsService Credentials,
            Func<IRefreshVocabularyTask> refreshVocabluaryTaskFactory,
            IMessageBus Messenger
            ) {
            this.OnActivation()
                .SelectMany(_ => Credentials.CurrentCredentials().Where(cred => cred != null).FirstAsync())
                .TakeUntil(this.OnDeactivation())
                .Subscribe(login => {
                    var refreshTask = refreshVocabluaryTaskFactory();
                    refreshTask.Start(login)
                        .Subscribe(_ => { }, () => {
                            Messenger.SendMessage<EventMessage>(EventMessage.Default, MessageContracts.REFRESH);
                            Messenger.SendMessage<Page>(Page.Home);
                        });
                });

        }
开发者ID:rollingthunder,项目名称:DiversityMobile,代码行数:18,代码来源:RefreshVocabularyVM.cs

示例3: InlineImageViewModel

        public InlineImageViewModel(string contentType, Upload upload, IMessageBus bus, Func<string, IImageView> imageViewCreator)
            : base(upload)
        {
            _imageViewCreator = imageViewCreator;
            ShowFullSizeImageCommand = new ReactiveCommand(
                this.ObservableForProperty(vm => vm.File).Select(c => c.Value != null));
            ShowFullSizeImageCommand.Subscribe(ViewImage);
            bus.Listen<FileDownloadedMessage>().Where(msg => msg.Url == Upload.FullUrl)
                .SubscribeUI(msg =>
                    {
                        File = msg.File;
                        ShowAnimated = contentType.Equals("image/gif", StringComparison.OrdinalIgnoreCase);
                        ShowUnanimated = !ShowAnimated;
                    });

            bus.SendMessage(new RequestDownloadFileMessage(Upload.FullUrl));
        }
开发者ID:Doomblaster,项目名称:MetroFire,代码行数:17,代码来源:InlineUploadViewModel.cs

示例4: InlineUploadViewModel

        public InlineUploadViewModel(IMessageBus bus, Message message, Func<string, IImageView> imageViewCreator)
        {
            _bus = bus;
            _imageViewCreator = imageViewCreator;

            var requestUploadMessage = new RequestUploadMessage(message.RoomId, message.Id);
            _bus.Listen<UploadReceivedMessage>().Where(msg => msg.Correlation == requestUploadMessage.Correlation)
                .SubscribeUI(UploadReceived);
            _bus.SendMessage(requestUploadMessage);
        }
开发者ID:Doomblaster,项目名称:MetroFire,代码行数:10,代码来源:InlineUploadViewModel.cs

示例5: MainViewModel

        public MainViewModel(IAppBootstrapper bootstrapper, IMessageBus messageBus)
            : base(bootstrapper, messageBus)
        {
            base.PathSegment = Constants.PATH_SEGMENT_MAIN;

            #region FilterData Configuration

            this.ObservableForProperty(vm => vm.FilterTerm)
                .Throttle(TimeSpan.FromMilliseconds(300), RxApp.MainThreadScheduler)
                .Select(v => v.Value)
                .DistinctUntilChanged()
                .Subscribe(v =>
                {
                    if (string.IsNullOrEmpty(v))
                    {
                        Routes = SourceRoutes;
                    }
                    else
                    {
                        IList<Route> resultList = new ObservableCollection<Route>();
                        foreach (Route route in SourceRoutes)
                        {
                            if (route.RouteName.Contains(v))
                            {
                                resultList.Add(route);
                            }
                        }
                        Routes = resultList;
                    }
                });

            #endregion FilterData Configuration

            #region Navigation Configuration
            // RouteView
            this.ObservableForProperty(vm => vm.SelectedRoute)
                .Where(v => null != v.Value)
                .Select(v => v.Value)
                //.DistinctUntilChanged()
                .Subscribe(r =>
                {
                    base.HostScreen.Router.Navigate.Execute(new RouteViewModel(base.HostBootstrapper, base.HostMessageBus, r));

                    this.SelectedRoute = null;
                });

            // SettingsView
            NavigateSettingsCommand = ReactiveCommand.Create();

            NavigateSettingsCommand.Subscribe(_ =>
            {
                base.HostScreen.Router.Navigate.Execute(new SettingsViewModel(base.HostBootstrapper, base.HostMessageBus));
            });

            #endregion Navigation Configuration

            #region Refresh Data Configuration

            RefreshCommand = ReactiveCommand.Create(this.WhenAny(vm => vm.IsBusy, r => !r.Value));

            RefreshCommand.Subscribe(async _ =>
            {
                await RequestInternetRoutes();
            });

            // don't use ToProperty(), because the ToProperty() is a Lazy Observation
            // https://github.com/reactiveui/ReactiveUI/blob/master/docs/basics/to-property.md
            this.WhenAny(vm => vm.IsBusy, x => x.Value)
                .Select(x => !x)
                .Subscribe(x =>
                {
                    IsEnabled = x;
                });

            #endregion Refresh Data Configuration

            #region Location Configuration

            messageBus.Listen<bool>(Constants.SETTINGS_IS_LOCATION_ENABLED).Subscribe(x =>
            {
                IsFlipSegmentsNearbyEnabled = x;
            });

            LocationCommand = ReactiveCommand.Create(this.WhenAny(vm => vm.IsBusy, r => !r.Value));

            LocationCommand.Subscribe(async _ =>
            {
                IsBusy = true;

                messageBus.SendMessage<string>(Constants.MSG_MAP_LOCATION_GET, Constants.MSGBUS_TOKEN_MESSAGEBAR);

                Geolocator geolocator = new Geolocator { ReportInterval = 1000, DesiredAccuracy = PositionAccuracy.High, DesiredAccuracyInMeters = 10, MovementThreshold = 5 };
                //geolocator.StatusChanged += geolocator_StatusChanged;
                try
                {
                    Geoposition location = await geolocator.GetGeopositionAsync(TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(5));

                    if (location.Coordinate.Point.Position.Latitude == HostBootstrapper.MyPosition.Latitude && location.Coordinate.Point.Position.Longitude == HostBootstrapper.MyPosition.Longitude)
                    {
#if DEBUG
//.........这里部分代码省略.........
开发者ID:xepher,项目名称:uwp-wxbus,代码行数:101,代码来源:MainViewModel.cs

示例6: LoginViewModel

        public LoginViewModel(IMessageBus bus, ILoginInfoStorage storage)
        {
            _bus = bus;

            _isTokenValid = this.ObservableToProperty(
                this.ObservableForProperty(vm => vm.Token).Select(t => !String.IsNullOrEmpty(t.Value)),
                vm => vm.IsTokenValid);
            LoginCommand = new ReactiveCommand(
                this.WhenAny(
                    vm => vm.IsAccountNameVerified,
                    vm => vm.IsTokenValid,
                    (verified, token) => verified.Value && token.Value
                    ));
            _bus.RegisterSourceAndHandleReply<RequestLoginMessage, RequestLoginResponse>(
                LoginCommand.Select(_ => new RequestLoginMessage(new LoginInfo(Account, Token)))
                    .Do(_ => IsLoggingIn = true)
                    .Do(_ => IsTokenInError = false),

                res =>
                    {
                        IsLoggingIn = false;
                        if (res.SuccessFul)
                        {
                            storage.PersistLoginInfo(new LoginInfo(Account, Token));
                            IsTokenInError = false;
                            _bus.SendMessage(new ActivateMainModuleMessage(ModuleNames.MainCampfireView));
                        }
                        else
                        {
                            IsTokenInError = true;
                        }
                    });

            RetryCommand = new ReactiveCommand();

            _bus.RegisterSourceAndHandleReply<RequestCheckAccountName, RequestCheckAccountNameReply>(
                this.ObservableForProperty(vm => vm.Account)
                .DistinctUntilChanged()
                .Select(_ => Unit.Default)
                .Throttle(TimeSpan.FromSeconds(1), RxApp.TaskpoolScheduler)
                .Merge(RetryCommand.Select(_ => Unit.Default))
                .Do(_ =>
                {
                    IsAccountNameVerified = false;
                    IsAccountNameInError = String.IsNullOrEmpty(Account);
                    ShowConnectionError = false;
                })
                .Where(_ => !String.IsNullOrEmpty(Account))
                .Select(_ => new RequestCheckAccountName(Account))
                .Do(_ => IsVerifyingAccountInProgress = true)
                .Do(msg => _accountNameCorrelationId = msg.CorrelationId),

                rep =>
                {
                    IsVerifyingAccountInProgress = false;
                    IsAccountNameVerified = rep.Result;
                    IsAccountNameInError = !rep.Result;
                },

                ex =>
                {
                    IsVerifyingAccountInProgress = false;
                    IsAccountNameVerified = false;
                    IsAccountNameInError = true;
                    ShowConnectionError = true;
                    ConnectionErrorMessage = ex.Message;
                });

            ProxySettingsCommand = new ReactiveCommand();
            _bus.RegisterMessageSource(ProxySettingsCommand.Select(_ => new NavigateSettingsPageMessage(SettingsPageNames.Network)));

            LoginInfo info = storage.GetStoredLoginInfo();
            if (info != null)
            {
                Token = info.Token;
                Account = info.Account;
            }
        }
开发者ID:Doomblaster,项目名称:MetroFire,代码行数:78,代码来源:LoginViewModel.cs

示例7: SendMessage

 public void SendMessage(IMessageBus messageBus)
 {
     messageBus.SendMessage(new object());
 }
开发者ID:ArturPhilibin,项目名称:ReactiveUiMessageBusMemoryTests,代码行数:4,代码来源:ViewModel.cs


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