當前位置: 首頁>>代碼示例>>C#>>正文


C# BindingBuilder.GetData方法代碼示例

本文整理匯總了C#中BindingBuilder.GetData方法的典型用法代碼示例。如果您正苦於以下問題:C# BindingBuilder.GetData方法的具體用法?C# BindingBuilder.GetData怎麽用?C# BindingBuilder.GetData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BindingBuilder的用法示例。


在下文中一共展示了BindingBuilder.GetData方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ParserShouldParseSingleExpression2

        public void ParserShouldParseSingleExpression2()
        {
            const string targetPath = "Text";
            const string sourcePath = "SourceText";
            const string binding = "Text $context.SourceText";
            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);
            BindingSourceShouldBeValid(source, AttachedMemberConstants.DataContext + "." + sourcePath, target);
        }
開發者ID:windygu,項目名稱:MugenMvvmToolkit,代碼行數:16,代碼來源:BindingParserTest.cs

示例2: ParserShouldParseSingleExpression1

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

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

            var sources = context.GetData(BindingBuilderConstants.Sources);
            IObserver source = sources.Single().Invoke(context);
            BindingSourceShouldBeValidDataContext(target, source, sourcePath);
        }
開發者ID:dbeattie71,項目名稱:MugenMvvmToolkit,代碼行數:16,代碼來源:BindingParserTest.cs

示例3: 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

示例4: 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

示例5: 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

示例6: BuilderShouldUseSourceObject1

        public void BuilderShouldUseSourceObject1()
        {
            const string targetPath = "Text";
            const string sourcePath = "IntProperty";
            var targetObj = new object();
            var sourceObj = new BindingSourceModel();
            var builder = new BindingBuilder();
            builder.Bind(targetObj, targetPath).To(sourceObj, sourcePath);

            IList<Func<IDataContext, IBindingSource>> sources = builder.GetData(BindingBuilderConstants.Sources);
            IBindingSource source = sources.Single().Invoke(builder);
            BindingParserTest.BindingSourceShouldBeValid(source, sourcePath, sourceObj);
        }
開發者ID:windygu,項目名稱:MugenMvvmToolkit,代碼行數:13,代碼來源:BindingSyntaxExtensionsTest.cs

示例7: BuilderShouldUseBindingContextExtension4

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

            IList<Func<IDataContext, IBindingSource>> sources = builder.GetData(BindingBuilderConstants.Sources);
            IBindingSource source = sources.Single().Invoke(builder);
            source.Path.Path.ShouldEqual(AttachedMemberConstants.DataContext + "." + sourcePath);
        }
開發者ID:windygu,項目名稱:MugenMvvmToolkit,代碼行數:12,代碼來源:BindingSyntaxExtensionsTest.cs

示例8: BuilderShouldUseResourceMethod2

        public void BuilderShouldUseResourceMethod2()
        {
            const string key = "key";
            var builder = new BindingBuilder();
            var sourceModel = new BindingSourceModel();
            var result = new BindingSourceModel { ObjectProperty = "Test" };
            BindingServiceProvider.ResourceResolver.AddMethod<string, object, BindingSourceModel>(key, (s1, s2, context) =>
            {
                s1.ShouldEqual(key);
                s2.ShouldEqual(builder);
                context.ShouldEqual(builder);
                return result;
            });
            builder.Bind(sourceModel, "empty").To<BindingSourceModel>(() => model => BindingSyntaxEx.ResourceMethod<BindingSourceModel>(key, key, builder).ObjectProperty);

            var sources = builder.GetData(BindingBuilderConstants.Sources);
            sources.Count.ShouldEqual(1);
            sources[0].Invoke(builder).Path.Path.ShouldEqual(string.Empty);
            var expression = builder.GetData(BindingBuilderConstants.MultiExpression);
            expression(builder, Empty.Array<object>()).ShouldEqual(result.ObjectProperty);
        }
開發者ID:windygu,項目名稱:MugenMvvmToolkit,代碼行數:21,代碼來源:BindingSyntaxExtensionsTest.cs

示例9: BuilderShouldUseGetErrorsMethod3

        public void BuilderShouldUseGetErrorsMethod3()
        {
            var builder = new BindingBuilder();
            var sourceModel = new BindingSourceModel();
            builder.Bind(sourceModel, "empty").To(sourceModel, () => model => BindingSyntaxEx.GetErrors("1", "2", model.ObjectProperty));

            var source = builder.GetData(BindingBuilderConstants.Sources).Single().Invoke(builder);
            source.Path.Path.ShouldEqual(GetMemberPath(sourceModel, model => model.ObjectProperty));
            source.GetSource(true).ShouldEqual(sourceModel);

            var behavior = builder.GetOrAddBehaviors().OfType<NotifyDataErrorsAggregatorBehavior>().Single();
            behavior.ErrorPaths.SequenceEqual(new[] { "1", "2" }).ShouldBeTrue();
            builder.AddOrUpdate(BindingConstants.Binding, new DataBindingMock { Behaviors = new[] { behavior } });

            var expression = builder.GetData(BindingBuilderConstants.MultiExpression);
            behavior.Errors = new List<object> { "test" };
            expression(builder, new object[] { sourceModel }).ShouldEqual(behavior.Errors);
        }
開發者ID:windygu,項目名稱:MugenMvvmToolkit,代碼行數:18,代碼來源:BindingSyntaxExtensionsTest.cs

示例10: BuilderShouldUseSelfExpression1

        public void BuilderShouldUseSelfExpression1()
        {
            var builder = new BindingBuilder();
            var sourceModel = new BindingSourceModel();
            builder.Bind(sourceModel, "empty").To<BindingSourceModel>(() => model => BindingSyntaxEx.Self<BindingSourceModel>());

            var source = builder.GetData(BindingBuilderConstants.Sources).Single().Invoke(builder);
            builder.GetData(BindingBuilderConstants.MultiExpression).ShouldBeNull();
            source.Path.IsEmpty.ShouldBeTrue();
            source.GetSource(true).ShouldEqual(sourceModel);
            var pathMembers = source.GetPathMembers(true);
            pathMembers.LastMember.GetValue(pathMembers.PenultimateValue, null).ShouldEqual(sourceModel);
        }
開發者ID:windygu,項目名稱:MugenMvvmToolkit,代碼行數:13,代碼來源:BindingSyntaxExtensionsTest.cs

示例11: BuilderShouldUseConverterCulture3

 public void BuilderShouldUseConverterCulture3()
 {
     var builder = new BindingBuilder();
     builder.Bind(CultureInfo.InvariantCulture, "test").To("test").WithConverterCulture(() => o => BindingSyntaxEx.Self<CultureInfo>());
     builder.GetData(BindingBuilderConstants.ConverterCulture).Invoke(builder).ShouldEqual(CultureInfo.InvariantCulture);
 }
開發者ID:windygu,項目名稱:MugenMvvmToolkit,代碼行數:6,代碼來源:BindingSyntaxExtensionsTest.cs

示例12: BuilderShouldUseConverterCulture2

 public void BuilderShouldUseConverterCulture2()
 {
     Func<IDataContext, CultureInfo> culture = context => null;
     var builder = new BindingBuilder();
     builder.Bind(new object(), "test").To("test").WithConverterCulture(culture);
     builder.GetData(BindingBuilderConstants.ConverterCulture).ShouldEqual(culture);
 }
開發者ID:windygu,項目名稱:MugenMvvmToolkit,代碼行數:7,代碼來源:BindingSyntaxExtensionsTest.cs

示例13: BuilderShouldUseConverterCulture1

 public void BuilderShouldUseConverterCulture1()
 {
     var culture = CultureInfo.InvariantCulture;
     var builder = new BindingBuilder();
     builder.Bind(new object(), "test").To("test").WithConverterCulture(culture);
     builder.GetData(BindingBuilderConstants.ConverterCulture).Invoke(builder).ShouldEqual(culture);
 }
開發者ID:windygu,項目名稱:MugenMvvmToolkit,代碼行數:7,代碼來源:BindingSyntaxExtensionsTest.cs

示例14: BuilderShouldUseDelayBehaviorTarget

 public void BuilderShouldUseDelayBehaviorTarget()
 {
     var builder = new BindingBuilder();
     builder.Bind(new object(), "test").To("test").WithDelay(10, true);
     var behavior = builder.GetData(BindingBuilderConstants.Behaviors).OfType<DelayBindingBehavior>().Single();
     behavior.Delay.ShouldEqual(10);
     behavior.IsTarget.ShouldBeTrue();
 }
開發者ID:windygu,項目名稱:MugenMvvmToolkit,代碼行數:8,代碼來源:BindingSyntaxExtensionsTest.cs

示例15: BuilderShouldUseFallback3

 public void BuilderShouldUseFallback3()
 {
     var builder = new BindingBuilder();
     builder.Bind(builder, "test").To("test").WithFallback(() => o => BindingSyntaxEx.Self<object>());
     builder.GetData(BindingBuilderConstants.Fallback).Invoke(builder).ShouldEqual(builder);
 }
開發者ID:windygu,項目名稱:MugenMvvmToolkit,代碼行數:6,代碼來源:BindingSyntaxExtensionsTest.cs


注:本文中的BindingBuilder.GetData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。