本文整理汇总了C#中MugenMvvmToolkit.Test.TestModels.BindingSourceModel.RaiseEvent方法的典型用法代码示例。如果您正苦于以下问题:C# BindingSourceModel.RaiseEvent方法的具体用法?C# BindingSourceModel.RaiseEvent怎么用?C# BindingSourceModel.RaiseEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MugenMvvmToolkit.Test.TestModels.BindingSourceModel
的用法示例。
在下文中一共展示了BindingSourceModel.RaiseEvent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMemberGenericObserveEventTest
public void CreateMemberGenericObserveEventTest()
{
bool isInvoked = false;
var listenerMock = new EventListenerMock
{
Handle = (o, o1) => isInvoked = true
};
var source = new BindingSourceModel();
const string path = "path";
source.RaiseEvent();
var property = AttachedBindingMember.CreateMember<BindingSourceModel, string>(path, (info, o) => null,
(info, o, v) => { }, BindingSourceModel.EventName);
IDisposable subscriber = property.TryObserve(source, listenerMock);
source.RaiseEvent();
isInvoked.ShouldBeTrue();
subscriber.ShouldNotBeNull();
isInvoked = false;
source.RaiseEvent();
isInvoked.ShouldBeTrue();
subscriber.Dispose();
isInvoked = false;
source.RaiseEvent();
isInvoked.ShouldBeFalse();
}
示例2: ExecuteShouldCallCmdExecuteMethodOneTimeModeAfterDispose
public void ExecuteShouldCallCmdExecuteMethodOneTimeModeAfterDispose()
{
var parameter = new object();
bool isInvoked = false;
var command = new RelayCommand(o =>
{
o.ShouldEqual(parameter);
isInvoked = true;
});
var srcAccessor = new BindingSourceAccessorMock();
var source = new BindingSourceModel();
var ctx = new DataContext(BindingBuilderConstants.Behaviors.ToValue(new List<IBindingBehavior> { new OneTimeBindingMode() }));
var accessor = GetAccessor(source, BindingSourceModel.EventName, ctx, false, d => parameter);
srcAccessor.GetValue = (info, context, arg3) => command;
accessor.SetValue(srcAccessor, EmptyContext, true);
accessor.Dispose();
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
source.RaiseEvent();
isInvoked.ShouldBeTrue();
isInvoked = false;
source.RaiseEvent();
isInvoked.ShouldBeTrue();
}
示例3: ExecuteShouldCallCmdExecuteMethod
public void ExecuteShouldCallCmdExecuteMethod()
{
var parameter = new object();
bool isInvoked = false;
var command = new RelayCommand(o =>
{
o.ShouldEqual(parameter);
isInvoked = true;
});
var srcAccessor = new BindingSourceAccessorMock();
var source = new BindingSourceModel();
var accessor = GetAccessor(source, BindingSourceModel.EventName, EmptyContext, false, d => parameter);
srcAccessor.GetValue = (info, context, arg3) => command;
accessor.SetValue(srcAccessor, EmptyContext, true);
source.RaiseEvent();
isInvoked.ShouldBeTrue();
isInvoked = false;
source.RaiseEvent();
isInvoked.ShouldBeTrue();
}
示例4: WeakEventManagerShouldRemoveWeakListenersEvent
public void WeakEventManagerShouldRemoveWeakListenersEvent()
{
const int count = 100;
var model = new BindingSourceModel();
var listeners = new List<WeakReference>();
IWeakEventManager weakEventManager = CreateWeakEventManager();
for (int i = 0; i < count; i++)
{
var listenerMock = new EventListenerMock();
weakEventManager.TrySubscribe(model, BindingSourceModel.EventName, listenerMock);
listeners.Add(new WeakReference(listenerMock));
listenerMock.Handle = (o, o1) => { };
}
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
model.RaiseEvent();
model.RaiseEvent();
listeners.All(reference => reference.Target == null).ShouldBeTrue();
}
示例5: WeakEventManagerShouldSubscribeAndUnsubscribeEventSeveralSources
public void WeakEventManagerShouldSubscribeAndUnsubscribeEventSeveralSources()
{
const int count = 100;
var model = new BindingSourceModel();
var listeners = new List<EventListenerMock>();
var invokedItems = new List<EventListenerMock>();
IWeakEventManager weakEventManager = CreateWeakEventManager();
for (int i = 0; i < count; i++)
{
var listenerMock = new EventListenerMock();
var disposable = weakEventManager.TrySubscribe(model, BindingSourceModel.EventName, listenerMock);
listeners.Add(listenerMock);
listenerMock.Handle = (o, o1) =>
{
invokedItems.Add(listenerMock);
disposable.Dispose();
};
}
model.RaiseEvent();
model.RaiseEvent();
invokedItems.Count.ShouldEqual(count);
foreach (var listener in listeners)
invokedItems.Contains(listener).ShouldBeTrue();
}
示例6: WeakEventManagerShouldSubscribeAndUnsubscribeEvent
public void WeakEventManagerShouldSubscribeAndUnsubscribeEvent()
{
int invokedCount = 0;
var model = new BindingSourceModel();
var listenerMock = new EventListenerMock();
IWeakEventManager weakEventManager = CreateWeakEventManager();
var disposable = weakEventManager.TrySubscribe(model, BindingSourceModel.EventName, listenerMock);
listenerMock.Handle = (o, o1) => invokedCount++;
invokedCount.ShouldEqual(0);
model.RaiseEvent();
invokedCount.ShouldEqual(1);
disposable.Dispose();
model.RaiseEvent();
invokedCount.ShouldEqual(1);
}