當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。