本文整理汇总了C#中Messenger.Send方法的典型用法代码示例。如果您正苦于以下问题:C# Messenger.Send方法的具体用法?C# Messenger.Send怎么用?C# Messenger.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Messenger
的用法示例。
在下文中一共展示了Messenger.Send方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainWindowViewModel
public MainWindowViewModel(Messenger messenger)
{
Workspaces = new ObservableCollection<IWorkspace>();
Workspaces.CollectionChanged += Workspaces_CollectionChanged;
SearchCustomerCommand = new RelayCommand(SearchCustomer);
CreateCustomerCommand = new RelayCommand(() => messenger.Send(new OpenDialogWindowMessage(new CustomerViewModel(new Customer()), r => MessageBox.Show(r.ToString()))));
}
示例2: Messager_Unsubscription_Test
public void Messager_Unsubscription_Test(int countSend)
{
var subscriber1 = new FakeSubscriber();
var subscriber2 = new FakeSubscriber();
var message = new FakeOneMessage { Text = "Test message" };
var messenger = new Messenger();
byte firstSubscriberNumber = 0;
byte secondSubscriberNumber = 0;
messenger.Subscribe<FakeOneMessage>(subscriber1, (s, m) =>
{
firstSubscriberNumber++;
messenger.Unsubscribe<FakeOneMessage>(subscriber1);
});
messenger.Subscribe<FakeOneMessage>(subscriber2, (s, m) =>
{
secondSubscriberNumber++;
});
for (int i = 0; i < countSend; i++)
{
messenger.Send(message);
}
Assert.AreEqual(1, firstSubscriberNumber);
Assert.AreEqual(countSend, secondSubscriberNumber);
}
示例3: HandleMessage
public override void HandleMessage(Message msg)
{
Message msg1 = Message.Obtain();
Bundle bundle = new Bundle();
bundle.PutString("arg1", "index.html");
bundle.PutString("arg2", "http://www.vogella.com/index.html");
msg1.Data = bundle;
Messenger replyto = new Messenger(msg.ReplyTo.Binder);
replyto.Send(msg1);
// Log.Error(this.Class.DeclaringClass.Class.Name, "Handlign message, ComputeService");
}
示例4: SutSubscribesToAddCmdApplicationConfigurationEvent
public void SutSubscribesToAddCmdApplicationConfigurationEvent(
Name aName,
IChannel<SaveCmdApplicationConfigurationCommand> channel,
CmdApplicationConfigurationViewModel vm,
[Frozen]Mock<ICmdApplicationConfigurationViewModelFactory> mockFactory,
Messenger messenger,
IFixture fixture)
{
fixture.Inject<IMessenger>(messenger);
var sut = fixture.Create<CmdApplicationConfigurationListViewModel>();
SetUpFactoryToReturnANewInstance(vm, mockFactory);
var expected = sut.ApplicationConfigurations.Count + 1;
messenger.Send(new AddCmdApplicationConfigurationEvent());
Assert.Equal(expected, sut.ApplicationConfigurations.Count);
}
示例5: CurrentProjectIsChangedOnMessage
public void CurrentProjectIsChangedOnMessage()
{
// Arrange
var messenger = new Messenger();
var projectListMock = new Mock<IProjectListViewModel>();
projectListMock.SetupGet( x => x.CurrentProject ).Verifiable();
var searcher = new EntrySearcher( projectListMock.Object, messenger );
// Act
messenger.Send( new CurrentProjectChangedMessage( null ) );
// Assert
projectListMock.VerifyGet( x => x.CurrentProject, Times.Exactly( 2 ) );
}
示例6: Messager_IncorrectSubscription_Test
public void Messager_IncorrectSubscription_Test()
{
var subscriber = new FakeSubscriber();
var message = new FakeTwoMessage();
var messenger = new Messenger();
FakeOneMessage receivedMessage = null;
messenger.Subscribe<FakeOneMessage>(subscriber, (s, m) =>
{
receivedMessage = m;
});
messenger.Send(message);
Assert.AreNotSame(message, receivedMessage);
}
示例7: Messager_CorrectSubscription_Test
public void Messager_CorrectSubscription_Test()
{
var subscriber = new FakeSubscriber();
var message = new FakeOneMessage { Text = "Test message" };
var messenger = new Messenger();
FakeOneMessage receivedMessage = null;
messenger.Subscribe<FakeOneMessage>(subscriber, (s, m) =>
{
receivedMessage = m;
});
messenger.Send(message);
Assert.AreSame(message, receivedMessage);
Assert.AreEqual(message.Text, receivedMessage.Text);
}
示例8: TestInstanceCreation
public void TestInstanceCreation()
{
const string TestContent = "abcd";
Reset();
var messenger = new Messenger();
messenger.Register<TestMessage>(this, m => StringContent = m.Content);
Assert.AreEqual(null, StringContent);
messenger.Send(new TestMessage
{
Content = TestContent
});
Assert.AreEqual(TestContent, StringContent);
}
示例9: TestMultipleMessengerInstances
public void TestMultipleMessengerInstances()
{
var messenger1 = new Messenger();
var messenger2 = new Messenger();
var recipient11 = new TestRecipient1();
var recipient12 = new TestRecipient1();
var recipient21 = new TestRecipient2();
var recipient22 = new TestRecipient2();
messenger1.Register<string>(recipient11, recipient11.ReceiveMessage);
messenger2.Register<string>(recipient12, recipient12.ReceiveMessage);
messenger1.Register<string>(recipient21, recipient21.ReceiveMessage);
messenger2.Register<string>(recipient22, recipient22.ReceiveMessage);
const string TestContent1 = "abcd";
const string TestContent2 = "efgh";
Assert.AreEqual(null, recipient11.ReceivedContentString);
Assert.AreEqual(null, recipient12.ReceivedContentString);
Assert.AreEqual(null, recipient21.ReceivedContentString);
Assert.AreEqual(null, recipient22.ReceivedContentString);
messenger1.Send(TestContent1);
Assert.AreEqual(TestContent1, recipient11.ReceivedContentString);
Assert.AreEqual(null, recipient12.ReceivedContentString);
Assert.AreEqual(TestContent1, recipient21.ReceivedContentString);
Assert.AreEqual(null, recipient22.ReceivedContentString);
messenger2.Send(TestContent2);
Assert.AreEqual(TestContent1, recipient11.ReceivedContentString);
Assert.AreEqual(TestContent2, recipient12.ReceivedContentString);
Assert.AreEqual(TestContent1, recipient21.ReceivedContentString);
Assert.AreEqual(TestContent2, recipient22.ReceivedContentString);
}
示例10: LoginQuery
void LoginQuery(Messenger messenger, string key, LoginQuery query)
{
messenger.Send("Database", query);
}
示例11: LoginAnswer
void LoginAnswer(Messenger messenger, string key, LoginAnswer query)
{
messenger.Send("Proxy", query);
}