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


C# TestModels.BindingSourceModel类代码示例

本文整理汇总了C#中MugenMvvmToolkit.Test.TestModels.BindingSourceModel的典型用法代码示例。如果您正苦于以下问题:C# BindingSourceModel类的具体用法?C# BindingSourceModel怎么用?C# BindingSourceModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BindingSourceModel类属于MugenMvvmToolkit.Test.TestModels命名空间,在下文中一共展示了BindingSourceModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WeakEventManagerShouldRemoveWeakListenersPropertyChanged

        public void WeakEventManagerShouldRemoveWeakListenersPropertyChanged()
        {
            const int count = 100;
            const string propertyName = "test";

            var model = new BindingSourceModel();
            var listeners = new List<WeakReference>();
            IWeakEventManager weakEventManager = CreateWeakEventManager();

            for (int i = 0; i < count; i++)
            {
                var listenerMock = new EventListenerMock();
                weakEventManager.Subscribe(model, propertyName, listenerMock);
                listeners.Add(new WeakReference(listenerMock));
                listenerMock.Handle = (o, o1) => { };
            }
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            model.OnPropertyChanged(propertyName + "1");
            model.OnPropertyChanged(propertyName);
            model.OnPropertyChanged(propertyName);

            listeners.All(reference => reference.Target == null).ShouldBeTrue();
        }
开发者ID:MuffPotter,项目名称:MugenMvvmToolkit,代码行数:26,代码来源:WeakEventManagerTest.cs

示例2: GetValueShouldReturnActualValueDoubleSource

        public void GetValueShouldReturnActualValueDoubleSource()
        {
            const string value = "100";
            bool isInvoked = false;
            var memberMock = new BindingMemberInfoMock();
            var sourceModel = new BindingSourceModel();
            string propertyName1 = GetMemberPath<BindingSourceModel>(model => model.IntProperty);
            string propertyName2 = GetMemberPath<BindingSourceModel>(model => model["test"]);
            var valueAccessor = new MultiBindingSourceAccessor(new[]
            {
                CreateSource(sourceModel, propertyName1),
                CreateSource(sourceModel, propertyName2),
            },
                (context, list) =>
                {
                    list.Count.ShouldEqual(2);
                    isInvoked = true;
                    context.ShouldEqual(EmptyContext);
                    list[0].ShouldEqual(sourceModel.IntProperty);
                    list[1].ShouldEqual(sourceModel["test"]);
                    return value;
                }, EmptyContext);
            valueAccessor.GetValue(memberMock, EmptyContext, true).ShouldEqual(value);
            isInvoked.ShouldBeTrue();

            isInvoked = false;
            sourceModel["test"] = propertyName1;
            sourceModel.IntProperty = int.MaxValue;
            valueAccessor.GetValue(memberMock, EmptyContext, true).ShouldEqual(value);
            isInvoked.ShouldBeTrue();
        }
开发者ID:sami1971,项目名称:MugenMvvmToolkit,代码行数:31,代码来源:MultiBindingSourceAccessorTest.cs

示例3: WeakEventManagerShouldSubscribeAndUnsubscribePropertyChangedEventSeveralSources

        public void WeakEventManagerShouldSubscribeAndUnsubscribePropertyChangedEventSeveralSources()
        {
            const int count = 100;
            const string propertyName = "test";

            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.Subscribe(model, propertyName, listenerMock);
                listeners.Add(listenerMock);
                listenerMock.Handle = (o, o1) =>
                {
                    invokedItems.Add(listenerMock);
                    disposable.Dispose();
                };
            }
            model.OnPropertyChanged(propertyName + "1");
            model.OnPropertyChanged(propertyName);
            model.OnPropertyChanged(propertyName);

            invokedItems.Count.ShouldEqual(count);
            foreach (var listener in listeners)
                invokedItems.Contains(listener).ShouldBeTrue();
        }
开发者ID:MuffPotter,项目名称:MugenMvvmToolkit,代码行数:29,代码来源:WeakEventManagerTest.cs

示例4: CmdShouldNotAddNotifierWhenCanExecuteNull

 public void CmdShouldNotAddNotifierWhenCanExecuteNull()
 {
     var notifier = new BindingSourceModel();
     var relayCommand = CreateCommand(NodoAction);
     relayCommand.AddNotifier(notifier).ShouldBeFalse();
     relayCommand.GetNotifiers().ShouldBeEmpty();
 }
开发者ID:dbeattie71,项目名称:MugenMvvmToolkit,代码行数:7,代码来源:RelayCommandTest.cs

示例5: GetValueShouldThrowExceptionInvalidValueIfFlagTrue

 public void GetValueShouldThrowExceptionInvalidValueIfFlagTrue()
 {
     var memberMock = new BindingMemberInfoMock();
     var sourceModel = new BindingSourceModel();
     const string propertyName = "invalid";
     var valueAccessor = new MultiBindingSourceAccessor(new[] { CreateSource(sourceModel, propertyName) },
         (context, list) => null, EmptyContext);
     ShouldThrow(() => valueAccessor.GetValue(memberMock, EmptyContext, true));
 }
开发者ID:sami1971,项目名称:MugenMvvmToolkit,代码行数:9,代码来源:MultiBindingSourceAccessorTest.cs

示例6: ObserverShouldThrowExceptionInvalidPath

        public void ObserverShouldThrowExceptionInvalidPath()
        {
            var model = new BindingSourceModel();
            var observer = CreateObserver(model, "invalid", false, optional: false);

            observer.Source.ShouldEqual(model);
            ShouldThrow(() =>
            {
                var members = observer.GetPathMembers(true);
            });
        }
开发者ID:dbeattie71,项目名称:MugenMvvmToolkit,代码行数:11,代码来源:ObserverTest.cs

示例7: ObserverShouldUseObjectAsSource

        public void ObserverShouldUseObjectAsSource()
        {
            var model = new BindingSourceModel();
            var propertyName = GetMemberPath<BindingSourceModel>(sourceModel => sourceModel.StringProperty);
            var observer = CreateObserver(model, propertyName, false);

            observer.Source.ShouldEqual(model);
            var members = observer.GetPathMembers(true);
            members.AllMembersAvailable.ShouldBeTrue();
            members.Members.Single().Type.ShouldEqual(typeof(string));
            observer.Path.Path.ShouldEqual(propertyName);
        }
开发者ID:sami1971,项目名称:MugenMvvmToolkit,代码行数:12,代码来源:ObserverTest.cs

示例8: ObserverShouldNotThrowExceptionInvalidPathOptional

        public void ObserverShouldNotThrowExceptionInvalidPathOptional()
        {
            var model = new BindingSourceModel();
            var observer = CreateObserver(model, "invalid", false, optional: true);

            observer.Source.ShouldEqual(model);
            var members = observer.GetPathMembers(true);
            members.AllMembersAvailable.ShouldBeFalse();

            members = observer.GetPathMembers(false);
            members.AllMembersAvailable.ShouldBeFalse();
        }
开发者ID:dbeattie71,项目名称:MugenMvvmToolkit,代码行数:12,代码来源:ObserverTest.cs

示例9: BuilderShouldUseTargetBindingContextForSource3

        public void BuilderShouldUseTargetBindingContextForSource3()
        {
            const string sourcePath = "IntProperty";
            var targetObj = new BindingSourceEventNotifierModel();
            var builder = new BindingBuilder();
            builder.Bind(targetObj, () => model => model.ObjectProperty).To(sourcePath);

            IList<Func<IDataContext, IBindingSource>> sources = builder.GetData(BindingBuilderConstants.Sources);
            IBindingSource source = sources.Single().Invoke(builder);
            BindingParserTest.BindingSourceShouldBeValidDataContext(targetObj, source, sourcePath);
            var sourceObj = new BindingSourceModel();
            BindingServiceProvider.ContextManager.GetBindingContext(targetObj).Value = sourceObj;
            BindingParserTest.BindingSourceShouldBeValidDataContext(targetObj, source, sourcePath);
        }
开发者ID:windygu,项目名称:MugenMvvmToolkit,代码行数:14,代码来源:BindingSyntaxExtensionsTest.cs

示例10: BuilderShouldUseTargetBindingContextForSource2

        public void BuilderShouldUseTargetBindingContextForSource2()
        {
            const string targetPath = "Text";
            const string sourcePath = "IntProperty";
            var targetObj = new object();
            var builder = new BindingBuilder();
            builder.Bind(targetObj, targetPath).To<BindingSourceModel>(() => (model, ctx) => model.IntProperty);

            IList<Func<IDataContext, IObserver>> sources = builder.GetData(BindingBuilderConstants.Sources);
            IObserver source = sources.Single().Invoke(builder);
            BindingParserTest.BindingSourceShouldBeValidDataContext(targetObj, source, sourcePath);
            var sourceObj = new BindingSourceModel();
            BindingServiceProvider.ContextManager.GetBindingContext(targetObj).Value = sourceObj;
            BindingParserTest.BindingSourceShouldBeValidDataContext(targetObj, source, sourcePath);
        }
开发者ID:sami1971,项目名称:MugenMvvmToolkit,代码行数:15,代码来源:BindingSyntaxExtensionsTest.cs

示例11: ObserverShouldRaiseValueChangedEventWhenPropertyChanged

        public void ObserverShouldRaiseValueChangedEventWhenPropertyChanged()
        {
            bool isInvoked = false;
            var model = new BindingSourceModel();
            var propertyName = GetMemberPath<BindingSourceModel>(sourceModel => sourceModel.StringProperty);
            var observer = CreateObserver(model, propertyName, false);
            observer.ValueChanged += (sender, args) => isInvoked = true;

            isInvoked = false;
            model.StringProperty = "test";
            isInvoked.ShouldBeTrue();
            isInvoked = false;

            model.IntProperty = 10;
            isInvoked.ShouldBeFalse();
        }
开发者ID:sami1971,项目名称:MugenMvvmToolkit,代码行数:16,代码来源:ObserverTest.cs

示例12: AutoPropertyTest

        public void AutoPropertyTest()
        {
            var source = new BindingSourceModel();
            const string path = "path";
            Type type = typeof(string);
            IAttachedBindingMemberInfo<object, object> property = AttachedBindingMember.CreateAutoProperty(path, type);
            property.Path.ShouldEqual(path);
            property.Type.ShouldEqual(type);
            property.CanRead.ShouldBeTrue();
            property.CanWrite.ShouldBeTrue();
            property.Member.ShouldBeNull();
            property.MemberType.ShouldEqual(BindingMemberType.Attached);

            property.GetValue(source, null).ShouldBeNull();
            property.SetValue(source, new object[] { path });
            property.GetValue(source, null).ShouldEqual(path);
        }
开发者ID:MuffPotter,项目名称:MugenMvvmToolkit,代码行数:17,代码来源:AttachedBindingMemberTest.cs

示例13: ProviderShouldReturnMemberForProperty

        public void ProviderShouldReturnMemberForProperty()
        {
            var model = new BindingSourceModel();
            var path = GetMemberPath(model, m => m.IntProperty);
            var provider = CreateMemberProvider();

            var member = provider.GetBindingMember(typeof(BindingSourceModel), path, true, true);
            member.CanRead.ShouldBeTrue();
            member.CanWrite.ShouldBeTrue();
            member.Type.ShouldEqual(typeof(int));
            member.MemberType.ShouldEqual(BindingMemberType.Property);
            member.Path.ShouldEqual(path);
            (member.Member is PropertyInfo).ShouldBeTrue();

            member.SetValue(model, new object[] { int.MaxValue });
            member.GetValue(model, null).ShouldEqual(int.MaxValue);
        }
开发者ID:MuffPotter,项目名称:MugenMvvmToolkit,代码行数:17,代码来源:BindingMemberProviderTest.cs

示例14: ProviderShouldReturnMemberForField

        public void ProviderShouldReturnMemberForField()
        {
            const string value = "value";
            var model = new BindingSourceModel();
            var path = GetMemberPath(model, m => m.PublicField);
            var provider = CreateMemberProvider();

            var member = provider.GetBindingMember(typeof(BindingSourceModel), path, true, true);
            member.CanRead.ShouldBeTrue();
            member.CanWrite.ShouldBeTrue();
            member.Type.ShouldEqual(typeof(string));
            member.MemberType.ShouldEqual(BindingMemberType.Field);
            member.Path.ShouldEqual(path);
            (member.Member is FieldInfo).ShouldBeTrue();

            member.SetValue(model, new object[] { value });
            member.GetValue(model, null).ShouldEqual(value);
        }
开发者ID:MuffPotter,项目名称:MugenMvvmToolkit,代码行数:18,代码来源:BindingMemberProviderTest.cs

示例15: ParserShouldUseTargetBindingContextForSource

        public void ParserShouldUseTargetBindingContextForSource()
        {
            const string targetPath = "Text";
            const string sourcePath = "IntProperty";
            const string binding = "Text IntProperty";
            var target = new object();
            IBindingParser bindingParser = CreateBindingParser();

            var context = new BindingBuilder(bindingParser.Parse(binding, EmptyContext, target, null).Single());
            IBindingPath path = context.GetData(BindingBuilderConstants.TargetPath);
            path.Path.ShouldEqual(targetPath);

            var sources = context.GetData(BindingBuilderConstants.Sources);
            IBindingSource source = sources.Single().Invoke(context);
            BindingSourceShouldBeValidDataContext(target, source, sourcePath);
            var sourceObj = new BindingSourceModel();
            BindingServiceProvider.ContextManager.GetBindingContext(target).Value = sourceObj;
            BindingSourceShouldBeValidDataContext(target, source, sourcePath);
        }
开发者ID:windygu,项目名称:MugenMvvmToolkit,代码行数:19,代码来源:BindingParserTest.cs


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