本文整理汇总了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);
}
});
}
示例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);
});
});
}
示例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));
}
示例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);
}
示例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
//.........这里部分代码省略.........
示例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;
}
}
示例7: SendMessage
public void SendMessage(IMessageBus messageBus)
{
messageBus.SendMessage(new object());
}