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


C# BindingSourceModel.RaiseEvent方法代码示例

本文整理汇总了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();
        }
开发者ID:MuffPotter,项目名称:MugenMvvmToolkit,代码行数:27,代码来源:AttachedBindingMemberTest.cs

示例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();
        }
开发者ID:sami1971,项目名称:MugenMvvmToolkit,代码行数:27,代码来源:SingleBindingSourceAccessorTest.cs

示例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();
        }
开发者ID:sami1971,项目名称:MugenMvvmToolkit,代码行数:21,代码来源:SingleBindingSourceAccessorTest.cs

示例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();
        }
开发者ID:MuffPotter,项目名称:MugenMvvmToolkit,代码行数:24,代码来源:WeakEventManagerTest.cs

示例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();
        }
开发者ID:MuffPotter,项目名称:MugenMvvmToolkit,代码行数:26,代码来源:WeakEventManagerTest.cs

示例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);
        }
开发者ID:MuffPotter,项目名称:MugenMvvmToolkit,代码行数:18,代码来源:WeakEventManagerTest.cs


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