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


C# BindingBuilder.Add方法代碼示例

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


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

示例1: BuilderShouldUseEventArgs2

        public void BuilderShouldUseEventArgs2()
        {
            var builder = new BindingBuilder();
            builder.Bind(new object(), "empty").To<BindingSourceModel>(() => model => BindingSyntaxEx.EventArgs<EventArgs>().GetType().Name);

            builder.Add(BindingConstants.CurrentEventArgs, EventArgs.Empty);
            var expression = builder.GetData(BindingBuilderConstants.MultiExpression);
            expression(builder, Empty.Array<object>()).ShouldEqual(EventArgs.Empty.GetType().Name);
        }
開發者ID:windygu,項目名稱:MugenMvvmToolkit,代碼行數:9,代碼來源:BindingSyntaxExtensionsTest.cs

示例2: BuilderShouldUseEventArgs3

        public void BuilderShouldUseEventArgs3()
        {
            var builder = new BindingBuilder();
            builder.Bind(new object(), "empty").To<BindingSourceModel>(() => model => BindingSyntaxEx.EventArgs<BindingSourceModel>().ObjectProperty);

            var sourceModel = new BindingSourceModel { ObjectProperty = "test" };
            builder.Add(BindingConstants.CurrentEventArgs, sourceModel);
            var expression = builder.GetData(BindingBuilderConstants.MultiExpression);
            expression(builder, Empty.Array<object>()).ShouldEqual(sourceModel.ObjectProperty);
        }
開發者ID:windygu,項目名稱:MugenMvvmToolkit,代碼行數:10,代碼來源:BindingSyntaxExtensionsTest.cs

示例3: BuilderShouldUseEventArgsForParameter2

        public void BuilderShouldUseEventArgsForParameter2()
        {
            var builder = new BindingBuilder();
            builder.Bind(new object(), "empty").To<BindingSourceModel>(() => m => m.IntProperty)
                .WithCommandParameter(() => model => BindingSyntaxEx.EventArgs<EventArgs>().GetType().Name);

            builder.Add(BindingConstants.CurrentEventArgs, EventArgs.Empty);
            var expression = builder.GetData(BindingBuilderConstants.CommandParameter);
            expression(builder).ShouldEqual(EventArgs.Empty.GetType().Name);
        }
開發者ID:windygu,項目名稱:MugenMvvmToolkit,代碼行數:10,代碼來源:BindingSyntaxExtensionsTest.cs

示例4: ParserShouldParseMultiExpressionWithConverter

        public void ParserShouldParseMultiExpressionWithConverter()
        {
            const string targetPath = "Text";
            const string sourcePath1 = "SourceText1";
            const string sourcePath2 = "SourceText2";
            const string converterName = "TestConverter";
            const string binding = "Text $TestConverter(SourceText1, SourceText2)";
            var target = new object();
            var args = new object[] { "tset", 1 };
            var sourceModel = new BindingSourceModel { IntProperty = int.MaxValue };
            var bindingMock = new DataBindingMock
            {
                TargetAccessor = new BindingSourceAccessorMock
                {
                    Source = new BindingSourceMock
                    {
                        GetPathMembers = b => new BindingPathMembersMock(this, BindingPath.Create("IntProperty"), new BindingMemberInfo("IntProperty", BindingSourceModel.IntPropertyInfo, typeof(BindingSourceModel)))
                    }
                }
            };

            var converterMock = new ValueConverterCoreMock
            {
                Convert = (o, type, arg3, arg4) =>
                {
                    type.ShouldEqual(BindingSourceModel.IntPropertyInfo.PropertyType);
                    o.ShouldEqual(args[0]);
                    arg3.ShouldEqual(args[1]);
                    return sourceModel;
                }
            };
            var provider = new BindingProvider();
            var resolver = new BindingResourceResolver();
            BindingServiceProvider.ResourceResolver = resolver;
            resolver.AddConverter(converterName, converterMock, true);
            IBindingParser bindingParser = CreateBindingParser(bindingProvider: provider);

            var context = new BindingBuilder(bindingParser.Parse(binding, EmptyContext, target, null).Single());
            context.Add(BindingConstants.Binding, bindingMock);

            IBindingPath path = context.GetData(BindingBuilderConstants.TargetPath);
            path.Path.ShouldEqual(targetPath);

            var expression = context.GetData(BindingBuilderConstants.MultiExpression);
            expression(context, args).ShouldEqual(sourceModel);

            var sources = context.GetData(BindingBuilderConstants.Sources);
            BindingSourceShouldBeValidDataContext(target, sources[0].Invoke(context), sourcePath1);
            BindingSourceShouldBeValidDataContext(target, sources[1].Invoke(context), sourcePath2);
        }
開發者ID:windygu,項目名稱:MugenMvvmToolkit,代碼行數:50,代碼來源:BindingParserTest.cs

示例5: ParserShouldParseExpressionWithEventArgs

        public void ParserShouldParseExpressionWithEventArgs()
        {
            const string targetPath = "Text";
            const string binding = @"Text $args";
            IBindingParser bindingParser = CreateBindingParser();

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

            context.Add(BindingConstants.CurrentEventArgs, EventArgs.Empty);
            var expression = context.GetData(BindingBuilderConstants.MultiExpression);
            expression(context, Empty.Array<object>()).ShouldEqual(EventArgs.Empty);
        }
開發者ID:windygu,項目名稱:MugenMvvmToolkit,代碼行數:14,代碼來源:BindingParserTest.cs

示例6: CreateBuildersFromString

 public IList<IBindingBuilder> CreateBuildersFromString(object target, string bindingExpression, IList<object> sources = null)
 {
     Should.NotBeNull(target, "target");
     Should.NotBeNullOrWhitespace(bindingExpression, "bindingExpression");
     try
     {
         var parserResult = Parser.Parse(bindingExpression, DataContext.Empty, target, sources);
         var result = new IBindingBuilder[parserResult.Count];
         for (int index = 0; index < parserResult.Count; index++)
         {
             var builder = new BindingBuilder(parserResult[index]);
             builder.Add(BindingBuilderConstants.BuildDelegate, _buildDelegate);
             result[index] = builder;
         }
         return result;
     }
     catch (Exception exception)
     {
         exception = new InvalidOperationException(exception.Message, exception);
         var builder = new BindingBuilder();
         builder.Add(BindingBuilderConstants.Target, target);
         builder.Add(ProviderConstant, this);
         builder.Add(ExceptionConstant, exception);
         builder.Add(BindingBuilderConstants.BuildDelegate, CreateInvalidaDataBindingDelegate);
         return new IBindingBuilder[] { builder };
     }
 }
開發者ID:sami1971,項目名稱:MugenMvvmToolkit,代碼行數:27,代碼來源:BindingProvider.cs

示例7: ParserShouldParseExpressionWithBinding

        public void ParserShouldParseExpressionWithBinding()
        {
            const string targetPath = "Text";
            const string binding = @"Text $binding";
            var dataContext = new DataContext();
            var bindingMock = new DataBindingMock { GetContext = () => dataContext };
            IBindingParser bindingParser = CreateBindingParser();

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

            context.Add(BindingConstants.Binding, bindingMock);
            var expression = context.GetData(BindingBuilderConstants.MultiExpression);
            expression(context, Empty.Array<object>()).ShouldEqual(bindingMock);
        }
開發者ID:dbeattie71,項目名稱:MugenMvvmToolkit,代碼行數:16,代碼來源:BindingParserTest.cs


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