本文整理汇总了C#中EventPublisher.GetEvent方法的典型用法代码示例。如果您正苦于以下问题:C# EventPublisher.GetEvent方法的具体用法?C# EventPublisher.GetEvent怎么用?C# EventPublisher.GetEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventPublisher
的用法示例。
在下文中一共展示了EventPublisher.GetEvent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EventPublisherGetEvent_UnitTest_SecondTimeForType_Existing
// ReSharper disable InconsistentNaming
public void EventPublisherGetEvent_UnitTest_SecondTimeForType_Existing()
// ReSharper restore InconsistentNaming
{
var publisher = new EventPublisher();
Assert.AreEqual(0, publisher.Count);
var first = publisher.GetEvent<object>();
Assert.AreEqual(1, publisher.Count);
Assert.IsNotNull(first);
Assert.IsInstanceOfType(first, typeof(IObservable<object>));
var second = publisher.GetEvent<object>();
Assert.AreEqual(1, publisher.Count);
Assert.IsNotNull(second);
Assert.IsInstanceOfType(second, typeof(IObservable<object>));
}
示例2: SubscribeToEvents
private void SubscribeToEvents()
{
_eventPublisher = new EventPublisher();
var numberCountedObserver = Observer.Create<NumberCountedEvent>(new Action<NumberCountedEvent>(OnNumberCounted));
_eventPublisher.GetEvent<NumberCountedEvent>()
.ObserveOnDispatcher()
.Subscribe(numberCountedObserver);
}
示例3: EventPublisherPublish_UnitTest_RegisteredType_FindsSubjectAndInvokesOnNext
// ReSharper disable InconsistentNaming
public void EventPublisherPublish_UnitTest_RegisteredType_FindsSubjectAndInvokesOnNext()
// ReSharper restore InconsistentNaming
{
var memo = new DesignValidationMemo();
var publisher = new EventPublisher();
var subscription = publisher.GetEvent<DesignValidationMemo>().Subscribe(m => Assert.AreSame(memo, m));
publisher.Publish(memo);
subscription.Dispose();
}
示例4: EventPublisherGetEvent_UnitTest_FirstTimeForType_New
// ReSharper disable InconsistentNaming
public void EventPublisherGetEvent_UnitTest_FirstTimeForType_New()
// ReSharper restore InconsistentNaming
{
var publisher = new EventPublisher();
Assert.AreEqual(0, publisher.Count);
var actual = publisher.GetEvent<object>();
Assert.AreEqual(1, publisher.Count);
Assert.IsNotNull(actual);
Assert.IsInstanceOfType(actual, typeof(IObservable<object>));
}
示例5: EventPublisherPublish_RemoveEvent_UnregisteredObjectType_NotRemoved
// ReSharper disable InconsistentNaming
public void EventPublisherPublish_RemoveEvent_UnregisteredObjectType_NotRemoved()
// ReSharper restore InconsistentNaming
{
var publisher = new EventPublisher();
var subscription = publisher.GetEvent<DesignValidationMemo>();
Assert.AreEqual(1, publisher.Count);
var result = publisher.RemoveEvent<Memo>();
Assert.AreEqual(1, publisher.Count);
Assert.IsFalse(result);
}
示例6: InitEventsLogic
private void InitEventsLogic()
{
EventPublisher = new EventPublisher();
// klikniecie na kategorie
EventPublisher.GetEvent<CollectionViewGroup>()
.Subscribe(cvg => FilteredUsers = new ObservableCollection<User>(cvg.Items.Cast<User>()));
// klikniecie na usera
EventPublisher.GetEvent<User>()
.Subscribe(user => SelectedUser = user);
// inicjalizacja edycji usera
EventPublisher.GetEvent<EditUserInitEvent>()
.Subscribe(
_ =>
{
EditUser =
new User
{
Address = SelectedUser.Address,
FirstName = SelectedUser.FirstName,
LastName = SelectedUser.LastName,
BirthDate = SelectedUser.BirthDate,
Type = SelectedUser.Type
};
EditModeNewUser = false;
});
EventPublisher.GetEvent<NewUserInitEvent>().Subscribe(_ =>
{
EditUser = new User();
EditModeNewUser = true;
});
// obsluga potwierdzenia edycji
EventPublisher.GetEvent<EditUserFinishedEvent>().Subscribe(_ =>
{
User selected;
if (EditModeNewUser)
{
Users.Add(EditUser);
selected = EditUser;
}
else
{
SelectedUser.FirstName = EditUser.FirstName;
SelectedUser.LastName = EditUser.LastName;
SelectedUser.Address = EditUser.Address;
SelectedUser.BirthDate = EditUser.BirthDate;
SelectedUser.Type = EditUser.Type;
selected = SelectedUser;
}
//refresh powoduje wynullowanie SelectedUser, why?
Cvs.View.Refresh();
FilteredUsers = new ObservableCollection<User>(Users);
SelectedUser = selected;
});
}